Authentication overview

OpenRegistry provides access to public sector data through its APIs, requiring authentication to manage usage, enforce access policies, and ensure data integrity. The primary method for authenticating requests to OpenRegistry's API is through the use of API keys. These keys serve as a unique identifier for your application and authorize it to access specific API endpoints and data sets based on your subscription plan.

Authentication is a critical security measure that verifies the identity of a user or system attempting to access a resource. In the context of APIs, authentication ensures that only authorized applications can make requests, preventing unauthorized data access and potential misuse of resources MDN Web Docs on HTTP Authentication. OpenRegistry's API key system is designed for straightforward integration while maintaining a necessary level of security for public data access.

When you make an API request to OpenRegistry, your API key is included in the request headers or as a query parameter. The OpenRegistry system then validates this key against its records, granting or denying access based on its validity and associated permissions. This mechanism allows OpenRegistry to meter usage, apply rate limits, and provide a secure environment for developers working with public data initiatives OpenRegistry API documentation.

Supported authentication methods

OpenRegistry primarily supports API key authentication for its services. This method is suitable for most server-side applications and scripts interacting with the OpenRegistry Core API and Data Enrichment Services.

Method When to Use Security Level
API Key Server-side applications, scripts, internal tools, and environments where the key can be securely stored. Moderate-High (when securely managed and transmitted over HTTPS)

API keys are typically long, randomly generated strings that act as a secret token. While they offer simplicity, their security heavily depends on how they are stored and transmitted. OpenRegistry mandates the use of HTTPS for all API communications, encrypting data in transit and protecting API keys from interception OpenRegistry API Reference.

Getting your credentials

To obtain your OpenRegistry API key, you need to sign up for an OpenRegistry account and navigate to your developer dashboard. The process typically involves these steps:

  1. Sign Up/Log In: Go to the OpenRegistry homepage and create a new account or log in to an existing one.
  2. Access Dashboard: Once logged in, locate and click on the 'Dashboard' or 'Developer Settings' link, usually found in the user profile menu.
  3. Generate API Key: Within the dashboard, there will be a section dedicated to API keys. You can typically generate a new key there. OpenRegistry allows you to generate multiple keys for different applications or environments (e.g., development, staging, production) to enhance security and key rotation practices.
  4. Copy and Store Securely: After generating the key, it will be displayed once. Copy it immediately and store it in a secure location. OpenRegistry generally does not store your secret key in a retrievable format after its initial display, meaning if you lose it, you will need to generate a new one.
  5. Configure Permissions (if applicable): Depending on your plan and specific needs, you might be able to configure specific permissions or scopes for your API key within the dashboard. This limits what the key can access, adhering to the principle of least privilege.

Always treat your API key as a sensitive secret, similar to a password. Never embed it directly into client-side code, commit it to version control systems like Git, or expose it in public-facing applications.

Authenticated request example

OpenRegistry API keys are typically passed in the Authorization header using the Bearer scheme or as a query parameter. The recommended method is via the Authorization header for enhanced security.

Using the Authorization header (Recommended)

Here's an example of an authenticated request using cURL and including the API key in the Authorization header:

curl -X GET \
  'https://api.openregistry.dev/v1/data/some_dataset' \
  -H 'Authorization: Bearer YOUR_OPENREGISTRY_API_KEY' \
  -H 'Content-Type: application/json'

Replace YOUR_OPENREGISTRY_API_KEY with your actual API key obtained from the OpenRegistry developer dashboard.

Using a query parameter (Less Recommended)

While less recommended due to potential logging of query parameters in server logs and browser histories, OpenRegistry also supports passing the API key as a query parameter:

curl -X GET \
  'https://api.openregistry.dev/v1/data/some_dataset?apiKey=YOUR_OPENREGISTRY_API_KEY' \
  -H 'Content-Type: application/json'

Again, ensure you replace the placeholder with your valid key. OpenRegistry's SDKs abstract these details, providing methods to configure your API key once and handle its inclusion in all subsequent requests. For example, in Python, you might initialize a client with your key:

import openregistry

openregistry.api_key = "YOUR_OPENREGISTRY_API_KEY"

# Make a request
data = openregistry.Data.retrieve("some_dataset")
print(data)

Refer to the specific OpenRegistry API reference documentation for detailed examples across supported SDKs (JavaScript/TypeScript, Python, Go, Ruby).

Security best practices

Securing your API keys is paramount to protecting your OpenRegistry account and the data you access. Adhere to these best practices:

  • Store API Keys Securely: Never hardcode API keys directly into your source code. Use environment variables, a secrets management service (e.g., AWS Secrets Manager, Google Cloud Secret Manager, Azure Key Vault), or a configuration file that is not committed to version control.
  • Use Environment Variables: For server-side applications, loading API keys from environment variables is a common and effective practice. This keeps keys out of your codebase.
  • Restrict Access: Limit who has access to your API keys. Only individuals or systems that absolutely require access should have it.
  • Least Privilege: If OpenRegistry supports it, configure your API keys with the minimum necessary permissions. For instance, if an application only needs to read data, do not grant it write or delete permissions.
  • HTTPS Everywhere: Always use HTTPS for all communications with the OpenRegistry API. This encrypts your API key and data in transit, protecting it from eavesdropping. OpenRegistry enforces HTTPS for all API endpoints.
  • Avoid Client-Side Exposure: Never expose your API keys in client-side code (e.g., JavaScript in a web browser, mobile app bundles). If your client-side application needs to interact with OpenRegistry, route requests through a secure backend server that holds the API key.
  • IP Whitelisting: If OpenRegistry offers IP whitelisting, configure it to allow requests only from a predefined set of trusted IP addresses. This adds an extra layer of security, even if a key is compromised.
  • Key Rotation: Regularly rotate your API keys. This practice minimizes the window of opportunity for a compromised key to be exploited. Set a schedule (e.g., quarterly, annually) for generating new keys and deactivating old ones.
  • Monitor Usage: Regularly review your API usage logs in the OpenRegistry dashboard for any unusual activity that might indicate a compromised key or unauthorized access.
  • Error Handling: Implement robust error handling for authentication failures. Avoid returning verbose error messages that could leak information about your authentication setup.

By following these guidelines, you can significantly reduce the risk of unauthorized access to your OpenRegistry account and ensure the integrity of your interactions with public sector data. For further security guidance, consult the OpenRegistry official documentation on security.