Getting started overview

This guide provides a focused approach to initiating development with the OpenCorporates API. OpenCorporates offers access to a global dataset of company registration information, officers, and filings. The API is designed for developers requiring programmatic access to public corporate data for applications in areas such as due diligence, compliance, and research.

The process of getting started involves three primary steps:

  1. Account Creation and API Key Generation: Registering on the OpenCorporates website and generating your unique API key.
  2. Making Your First Request: Constructing and executing a basic API call to retrieve company data, confirming successful authentication and connectivity.
  3. Exploring Further: Understanding the available data models and common next steps for integration.

The OpenCorporates API operates as a RESTful service, returning data in JSON format. All requests require an API key for authentication, which is passed as a query parameter. The documentation provides example code snippets in various programming languages, facilitating integration into existing projects.

Quick reference table

Step What to do Where
1. Sign Up Create an OpenCorporates account. OpenCorporates Homepage
2. Get API Key Locate and copy your API key from the developer dashboard. Account settings or API dashboard on opencorporates.com
3. Review Docs Understand the basic request structure and available endpoints. OpenCorporates API documentation
4. Construct Request Formulate your first API GET request with your key. Your preferred HTTP client or programming environment
5. Execute Request Send the request and observe the JSON response. Command line (cURL), browser, or code editor

Create an account and get keys

To begin interacting with the OpenCorporates API, you must first register for an account on the OpenCorporates website. This process establishes your user profile and is where you will obtain your unique API key.

  1. Navigate to the OpenCorporates Website: Go to the OpenCorporates homepage.
  2. Sign Up for an Account: Look for a "Sign Up" or "Register" option. You will typically be asked to provide an email address and create a password. OpenCorporates offers both a free tier for up to 1,000 API calls per month and various paid plans for higher usage. Complete the registration form.
  3. Access Your Dashboard: After successful registration and potentially email verification, log in to your new account. You will be directed to your user dashboard or profile page.
  4. Generate/Locate Your API Key: Within your dashboard, there should be a dedicated section for API access or developer settings. Here, your API key will be displayed. This key is a unique alphanumeric string that authenticates your requests to the OpenCorporates API. It is crucial to keep this key secure, as it grants access to your API quota. Copy this key, as you will need it for every API call. The OpenCorporates API documentation provides further details on key management.

OpenCorporates uses this API key to manage access permissions and track usage against your allocated quota. Misuse or sharing of API keys can lead to security vulnerabilities or exceeding rate limits. For production environments, it is recommended to manage API keys securely, for example, by storing them as environment variables rather than hardcoding them directly into your application code. This practice aligns with general API security guidelines recommended by organizations such as Google Cloud for API key security.

Your first request

Once you have obtained your API key, you can proceed to make your first request to the OpenCorporates API. This initial call serves to verify your setup and confirm that your API key is correctly integrated.

The OpenCorporates API provides various endpoints, but a simple way to start is by querying for a specific company. We will use the /companies/search endpoint. All API requests are made over HTTPS and return JSON data.

API endpoint structure

The base URL for the OpenCorporates API is https://api.opencorporates.com/v0.4. Your API key will be appended as a query parameter named api_token.

A basic search request for a company will look like this:

GET https://api.opencorporates.com/v0.4/companies/search?q=open+corporates&api_token=YOUR_API_TOKEN

Replace YOUR_API_TOKEN with the actual API key you obtained from your OpenCorporates account.

Making the request with cURL

cURL is a command-line tool and library for transferring data with URLs. It is pre-installed on most Unix-like systems and available for Windows, making it ideal for a quick test.

curl "https://api.opencorporates.com/v0.4/companies/search?q=open+corporates&api_token=YOUR_API_TOKEN"

Execute this command in your terminal, replacing YOUR_API_TOKEN. You should receive a JSON response similar to the following (truncated for brevity):

{
  "api_version": "0.4",
  "results": {
    "companies": [
      {
        "company": {
          "name": "OpenCorporates Ltd",
          "company_number": "07267923",
          "jurisdiction_code": "gb",
          "registered_address": "4th Floor, 18 St. Cross Street, London, EC1N 8UN",
          "opencorporates_url": "https://opencorporates.com/companies/gb/07267923",
          "current_status": "active",
          "company_type": "Private Limited Company"
          // ... more fields
        }
      }
    ],
    "total_count": 1,
    "per_page": 30,
    "page": 1
  }
}

A successful response indicates that your API key is valid and your application can reach the OpenCorporates API. The JSON object contains a results key, which holds an array of company objects matching your query.

Making the request with Python

For programmatic access, here's an example using Python's requests library:

import requests
import json

API_TOKEN = "YOUR_API_TOKEN"  # Replace with your actual API token
QUERY = "open corporates"

url = f"https://api.opencorporates.com/v0.4/companies/search?q={QUERY}&api_token={API_TOKEN}"

try:
    response = requests.get(url)
    response.raise_for_status() # Raise an HTTPError for bad responses (4xx or 5xx)
    data = response.json()
    print(json.dumps(data, indent=2))
except requests.exceptions.RequestException as e:
    print(f"An error occurred: {e}")

This script performs the same search and prints the JSON response. Ensure you have the requests library installed (pip install requests).

Common next steps

After successfully making your first API call, you can explore the OpenCorporates API's full capabilities. The following steps are typically undertaken by developers integrating OpenCorporates data:

  1. Explore Additional Endpoints: The OpenCorporates API documentation details various endpoints beyond company search, including specific company lookups by number, officer data, and filing information. Each endpoint supports different query parameters to refine results.
  2. Understand Data Structures: Familiarize yourself with the JSON response structures for different data types. OpenCorporates data can be complex due to the global nature of company registries, which have varying standards and data availability. The documentation provides examples of typical JSON payloads.
  3. Implement Error Handling: Robust applications should include comprehensive error handling. The OpenCorporates API uses standard HTTP status codes (e.g., 400 for bad request, 401 for unauthorized, 404 for not found, 429 for rate limiting, 500 for server errors) along with JSON error messages.
  4. Manage Rate Limits: Be aware of the API rate limits associated with your account tier. The free tier allows 1,000 API calls per month, while paid plans offer higher limits. Implement strategies like exponential backoff for retrying failed requests due to rate limiting or transient network issues. Information on rate limiting policies is available in the documentation.
  5. Paginating Results: For queries that return a large number of results, the API supports pagination. Parameters like page and per_page allow you to retrieve results in manageable chunks, optimizing data transfer and processing.
  6. Consider SDKs or Libraries: While OpenCorporates does not provide official SDKs, community-contributed libraries in languages like Python or Ruby might exist. These can abstract away the HTTP request details, providing a more idiomatic way to interact with the API. Always verify the reliability and maintenance status of third-party libraries.

Understanding these aspects will enable you to build more efficient and reliable applications utilizing OpenCorporates data.

Troubleshooting the first call

If your initial API call does not return the expected JSON response, consider the following common issues and troubleshooting steps:

  1. Incorrect API Key: Double-check that you have copied your API key correctly and replaced YOUR_API_TOKEN in the request URL. Even a single character mismatch will result in an authentication failure.
  2. Missing API Key: Ensure the api_token query parameter is present in your URL string. Requests without it will be rejected.
  3. HTTP Status Codes:
    • 401 Unauthorized: This usually means your API key is invalid or missing. Verify the key from your OpenCorporates account dashboard.
    • 400 Bad Request: The API server could not understand your request. Check for typos in endpoint names, malformed query parameters, or incorrect URL encoding.
    • 404 Not Found: The requested resource (or endpoint) does not exist. Confirm the base URL (https://api.opencorporates.com/v0.4) and the endpoint path (e.g., /companies/search) are accurate as per the OpenCorporates API documentation.
    • 429 Too Many Requests: You have exceeded your rate limit. This is less common on a first call but can occur if previous tests consumed your quota. Wait and retry, or check your account's usage limits.
    • 5xx Server Error: Indicate an issue on the OpenCorporates server side. These are typically temporary. Wait a few moments and retry the request. If the problem persists, check the OpenCorporates status page (if available) or contact their support.
  4. Network Connectivity: Confirm that your machine has an active internet connection and is not blocked by a firewall or proxy from accessing api.opencorporates.com.
  5. URL Encoding: Ensure that any query parameters containing special characters (like spaces in q=open corporates) are correctly URL-encoded. Most HTTP client libraries handle this automatically, but if manually constructing URLs, spaces should become %20 or +. The cURL example above uses double quotes around the URL, which typically handles simple spaces.
  6. JSON Parsing Errors: If you receive a response but your application fails to parse it, ensure you are attempting to parse it as JSON. An invalid API key might yield an HTML error page instead of JSON, which would cause a JSON parser to fail.
  7. Refer to Documentation: The OpenCorporates API documentation is the authoritative source for endpoint specifics, required parameters, and expected response formats. Review the relevant sections for the endpoint you are trying to access.

By systematically checking these points, you can identify and resolve most issues encountered during your initial OpenCorporates API integration.