SDKs overview

Lanyard offers Software Development Kits (SDKs) to simplify interaction with its event management API. These SDKs are designed to abstract the underlying HTTP requests and JSON parsing, allowing developers to integrate Lanyard's functionalities into their applications using familiar programming language constructs. The primary goal of these libraries is to reduce development time and potential errors when building custom event registration flows, attendee management systems, or integrating event data into other platforms.

The Lanyard API itself is RESTful, meaning it uses standard HTTP methods (GET, POST, PUT, DELETE) to perform operations on resources like events, attendees, and tickets. Responses are typically formatted in JSON. The SDKs wrap these interactions, providing methods that correspond to API endpoints and handling authentication, request serialization, and response deserialization automatically. This approach aligns with common practices for modern web service integrations, as seen in other API platforms like Stripe's payment processing or Twilio's communication services.

Developers benefit from type safety (where applicable by language), clearer error handling, and a more idiomatic coding experience compared to making raw HTTP requests. Lanyard maintains official SDKs for popular languages, and the developer community may contribute additional libraries.

Official SDKs by language

Lanyard provides official SDKs for Node.js, Python, and Ruby. These libraries are actively maintained and are the recommended way to interact with the Lanyard API for applications built in these languages. Each SDK is designed to reflect the Lanyard API reference efficiently, offering methods that map to API operations.

Language Package Name Install Command Maturity
Node.js @lanyardhq/lanyard-js npm install @lanyardhq/lanyard-js or yarn add @lanyardhq/lanyard-js Stable
Python lanyard-python pip install lanyard-python Stable
Ruby lanyard-ruby Add gem 'lanyard-ruby' to Gemfile then bundle install Stable

These official SDKs are hosted on their respective package managers and include comprehensive documentation on the Lanyard documentation portal, detailing initialization, authentication, and usage examples for various API endpoints. Developers are encouraged to refer to these resources for the most up-to-date information and best practices.

Installation

Installing Lanyard's SDKs follows standard practices for each programming ecosystem. Ensure you have the necessary package manager installed for your chosen language (npm/yarn for Node.js, pip for Python, Bundler for Ruby).

Node.js

To install the Node.js SDK, use npm or yarn:

# Using npm
npm install @lanyardhq/lanyard-js

# Using yarn
yarn add @lanyardhq/lanyard-js

This command downloads the package and its dependencies, making the Lanyard client available in your Node.js project. For further details, consult the Node.js SDK documentation.

Python

For Python projects, install the SDK using pip:

pip install lanyard-python

This command fetches the lanyard-python package from PyPI. Ensure your Python environment is active before running the command. More information is available in the Python SDK documentation.

Ruby

For Ruby applications, add the lanyard-ruby gem to your Gemfile and then run bundle install:

# In your Gemfile
gem 'lanyard-ruby'

# Then, run in your terminal
bundle install

This integrates the Lanyard Ruby client into your project via Bundler. Refer to the Ruby SDK documentation for detailed setup and usage instructions.

Quickstart example

The following example demonstrates how to initialize the Lanyard client and fetch a list of events using the Node.js SDK. Similar patterns apply to Python and Ruby, with language-specific syntax.

Node.js Example: Fetching Events

First, ensure you have your Lanyard API key. This key is used to authenticate your requests against the Lanyard API.

const Lanyard = require('@lanyardhq/lanyard-js');

// Initialize the Lanyard client with your API key
const lanyard = new Lanyard({ apiKey: 'YOUR_LANYARD_API_KEY' });

async function getEvents() {
  try {
    // Fetch a list of events from your Lanyard account
    const events = await lanyard.events.list();
    console.log('Successfully fetched events:');
    events.data.forEach(event => {
      console.log(`- ${event.name} (ID: ${event.id}) on ${new Date(event.startDate).toLocaleDateString()}`);
    });
  } catch (error) {
    console.error('Error fetching events:', error.message);
    // Log detailed error response if available
    if (error.response && error.response.data) {
      console.error('API Error Details:', error.response.data);
    }
  }
}

getEvents();

This snippet initializes the client with an API key and then calls the events.list() method to retrieve event data. The output will be a list of event names and IDs. Remember to replace 'YOUR_LANYARD_API_KEY' with your actual API key, which can be found in your Lanyard dashboard.

Python Example: Fetching Events

from lanyard_python import LanyardClient

# Initialize the Lanyard client with your API key
lanyard = LanyardClient(api_key='YOUR_LANYARD_API_KEY')

def get_events():
    try:
        # Fetch a list of events from your Lanyard account
        events = lanyard.events.list()
        print('Successfully fetched events:')
        for event in events.data:
            print(f"- {event.name} (ID: {event.id}) on {event.start_date.strftime('%Y-%m-%d')}")
    except Exception as e:
        print(f'Error fetching events: {e}')

if __name__ == '__main__':
    get_events()

This Python example mirrors the Node.js functionality, demonstrating how to initialize the client and iterate through fetched events. The LanyardClient handles authentication and request serialization.

Ruby Example: Fetching Events

require 'lanyard-ruby'

# Initialize the Lanyard client with your API key
lanyard = Lanyard::Client.new(api_key: 'YOUR_LANYARD_API_KEY')

def get_events
  begin
    # Fetch a list of events from your Lanyard account
    events = lanyard.events.list
    puts 'Successfully fetched events:'
    events.data.each do |event|
      puts "- #{event.name} (ID: #{event.id}) on #{Time.parse(event.start_date).strftime('%Y-%m-%d')}"
    end
  rescue StandardError => e
    puts "Error fetching events: #{e.message}"
  end
end

get_events

The Ruby example illustrates the use of the Lanyard::Client to perform the same operation, showcasing the idiomatic Ruby approach to interacting with the API.

Community libraries

While Lanyard provides official SDKs, the open-source community may develop and maintain additional client libraries or tools that extend Lanyard's functionality. These community-contributed projects are not officially supported by Lanyard but can offer alternative approaches or support for languages not covered by official SDKs.

Developers interested in community libraries should exercise due diligence:

  • Verify maintenance status: Check when the library was last updated and if it is actively maintained.
  • Review documentation: Ensure the library has clear documentation and examples.
  • Examine source code: Review the code for security practices, adherence to Lanyard's API specifications, and overall quality.
  • Check for community support: Look for issues, pull requests, and discussion forums to gauge community activity and support.

As of the last update, Lanyard's official documentation does not list specific community-maintained SDKs. Developers are encouraged to explore platforms like GitHub or package managers (e.g., PyPI, npm, RubyGems) for potential community contributions by searching for "Lanyard API" or "Lanyard client." Always prioritize security and reliability when choosing third-party libraries for production environments.