Getting started overview

OpenRegistry provides programmatic access to public sector and open government data. This guide outlines the essential steps to get started: account creation, API key generation, and executing a first API request. OpenRegistry offers SDKs for JavaScript/TypeScript, Python, Go, and Ruby to facilitate integration, alongside comprehensive documentation.

The core API allows developers to query various public datasets and utilize data enrichment services. A free tier is available, offering 1,000 requests per month, suitable for initial exploration and development (OpenRegistry pricing details). For more extensive usage, paid plans begin at $29/month.

The typical workflow for integrating with OpenRegistry involves:

  1. Signing up for an OpenRegistry account.
  2. Generating an API key or token for authentication.
  3. Making an authenticated request to an OpenRegistry endpoint.
  4. Processing the API response.

A quick-reference table for getting started is provided below:

Step What to Do Where
1. Sign Up Create a new OpenRegistry account. OpenRegistry Signup Page
2. Get API Keys Generate your API key from the dashboard. OpenRegistry Dashboard API Keys
3. Install SDK (Optional) Install the relevant SDK for your programming language. OpenRegistry SDK Documentation
4. Make First Request Execute a basic API call using your key. OpenRegistry API Reference
5. Explore Data Browse available datasets and endpoints. OpenRegistry Datasets Overview

Create an account and get keys

To access OpenRegistry's APIs, you must first create an account and obtain an API key. This key serves as your authentication credential for all API requests.

Account Creation

  1. Navigate to the OpenRegistry signup page.
  2. Provide the required information, typically including an email address and password.
  3. Verify your email address if prompted.
  4. Log in to your newly created account.

Upon successful signup, you will be directed to the OpenRegistry dashboard.

Generating API Keys

API keys are essential for authenticating your requests to OpenRegistry. They are unique identifiers that link your API calls to your account and usage limits.

  1. From your OpenRegistry dashboard, locate the "Settings" or "API Keys" section. This is typically found in the main navigation or user profile menu.
  2. Click on "Generate New API Key" or a similar button.
  3. You may be prompted to name your key for organizational purposes (e.g., "Development Key," "Production Server").
  4. The newly generated API key will be displayed. Copy this key immediately and store it securely. For security reasons, OpenRegistry may only display the full key once. Treat your API key like a password; do not expose it in client-side code, public repositories, or unsecured environments.
  5. For enhanced security, consider using environment variables to store your API key in development and production environments. For example, in a Unix-like system, you might set export OPENREGISTRY_API_KEY="your_api_key_here". This practice helps prevent sensitive information from being hardcoded.

OpenRegistry's API keys are typically long, alphanumeric strings. They are used in the Authorization header of your HTTP requests, often prefixed with Bearer, consistent with common Bearer token authentication schemes.

Your first request

With an account created and an API key in hand, you can now make your first request to OpenRegistry. This example uses the OpenRegistry Core API to retrieve a basic dataset. We will demonstrate using curl for a direct HTTP request and provide examples for JavaScript and Python using the official SDKs.

API Endpoint Structure

OpenRegistry API endpoints follow a RESTful design. The base URL for the API is typically https://api.openregistry.dev/v1/ (OpenRegistry API reference).

Using curl (HTTP Request)

The curl command-line tool is useful for testing API endpoints directly. Replace YOUR_API_KEY with your actual OpenRegistry API key.

curl -X GET \ 
  'https://api.openregistry.dev/v1/datasets/example_public_data' \ 
  -H 'Authorization: Bearer YOUR_API_KEY' \ 
  -H 'Content-Type: application/json'

This command sends a GET request to the /v1/datasets/example_public_data endpoint, authenticating with your API key in the Authorization header. The Content-Type header is included as a best practice, even for GET requests.

Using JavaScript SDK

First, install the JavaScript/TypeScript SDK:

npm install @openregistry/sdk

Then, make the request:

import { OpenRegistryClient } from '@openregistry/sdk';

const client = new OpenRegistryClient({ 
  apiKey: process.env.OPENREGISTRY_API_KEY 
});

async function getExampleData() {
  try {
    const response = await client.datasets.get('example_public_data');
    console.log('Example Data:', response.data);
  } catch (error) {
    console.error('Error fetching example data:', error.message);
  }
}

getExampleData();

This code initializes the OpenRegistry client with your API key (preferably from an environment variable) and then calls the get method on the datasets service to retrieve the example data.

Using Python SDK

First, install the Python SDK:

pip install openregistry-sdk

Then, make the request:

import os
from openregistry_sdk import OpenRegistryClient

client = OpenRegistryClient(api_key=os.environ.get("OPENREGISTRY_API_KEY"))

def get_example_data():
    try:
        response = client.datasets.get("example_public_data")
        print("Example Data:", response.data)
    except Exception as e:
        print(f"Error fetching example data: {e}")

if __name__ == "__main__":
    get_example_data()

Similar to the JavaScript example, the Python code initializes the client with the API key and fetches data using the SDK's methods. Using os.environ.get is a standard practice for securely accessing environment variables in Python.

Common next steps

After successfully making your first API call, consider these common next steps to further integrate OpenRegistry into your application:

  • Explore Available Datasets: Review the OpenRegistry datasets documentation to understand the range of public data available and identify the specific datasets relevant to your project.
  • Implement Error Handling: Integrate robust error handling into your application. The API reference details common error codes and messages, allowing your application to gracefully manage issues like invalid API keys, rate limits, or malformed requests.
  • Manage Rate Limits: Be aware of OpenRegistry's rate limits, especially on the free tier. Implement retry logic with exponential backoff for transient errors or rate limit responses. Information on rate limits is typically found in the OpenRegistry API reference on rate limits.
  • Utilize Data Enrichment Services: Explore OpenRegistry's data enrichment capabilities to enhance your existing data with public information.
  • Set Up Webhooks (if applicable): If OpenRegistry offers webhook functionality for real-time data updates or notifications, configure these to receive asynchronous information. For general guidance on webhook security, refer to Twilio's webhook security guide.
  • Monitor Usage: Regularly check your API usage in the OpenRegistry dashboard to stay within your plan limits and anticipate potential upgrades.
  • Explore Advanced Querying: Familiarize yourself with advanced filtering, sorting, and pagination options available through the API to retrieve precisely the data you need.
  • Consider a Sandbox Environment: OpenRegistry offers a sandbox environment for testing. Use this to develop and test new features without affecting your production usage or data.

Troubleshooting the first call

Encountering issues with your initial API request is common. Here are some troubleshooting steps:

  • Check API Key: Double-check that your API key is correct and has not expired or been revoked. Ensure there are no leading or trailing spaces.
  • Authentication Header: Verify that the Authorization header is correctly formatted as Bearer YOUR_API_KEY. A common mistake is omitting the "Bearer" prefix or incorrectly capitalizing it.
  • Endpoint URL: Confirm that the API endpoint URL is accurate (e.g., https://api.openregistry.dev/v1/) and that the specific resource path (e.g., /datasets/example_public_data) is correct according to the OpenRegistry API reference.
  • HTTP Method: Ensure you are using the correct HTTP method (e.g., GET for retrieving data, POST for creating data).
  • Network Connectivity: Confirm your development environment has an active internet connection and is not blocked by a firewall or proxy.
  • Rate Limits: If you receive a 429 Too Many Requests error, you have hit your rate limit. Wait a short period before retrying, or consider upgrading your plan.
  • Error Messages: Carefully read the error message returned in the API response. OpenRegistry's API is designed to provide informative error messages that can guide you to the root cause. Common HTTP status codes include:
    • 200 OK: Success.
    • 400 Bad Request: Your request was malformed (e.g., missing required parameters).
    • 401 Unauthorized: Invalid or missing API key.
    • 403 Forbidden: Your API key does not have permission to access the requested resource.
    • 404 Not Found: The requested resource does not exist.
    • 500 Internal Server Error: An unexpected error occurred on OpenRegistry's servers.
  • SDK Specific Issues: If using an SDK, ensure it is the latest version. Consult the OpenRegistry SDK documentation for specific initialization or method call details.
  • Consult Documentation: The OpenRegistry documentation is the primary resource for detailed information on endpoints, parameters, and troubleshooting.
  • Contact Support: If you've exhausted other options, contact OpenRegistry support for assistance.