Getting started overview

The INSPIREHEP API provides a programmatic interface to the High Energy Physics (HEP) database, enabling developers to integrate a range of research-related data into their applications. This includes access to scientific literature, author profiles, conference information, and job listings. The API is designed for public use, offering free access to its core functionalities without requiring specific API keys for standard data retrieval.

Interacting with the INSPIREHEP API typically involves sending HTTP GET requests to specific endpoints and parsing the resulting JSON responses. The architecture follows RESTful principles, allowing for flexible querying and data filtering through URL parameters. New users can quickly begin by understanding the basic endpoint structure and response formats to retrieve relevant information from the HEP community database.

This guide outlines the essential steps for developers to get started, from understanding API access requirements to making a first successful data request. It also covers common next steps for further integration and provides troubleshooting tips for initial setup challenges.

Create an account and get keys

Unlike many commercial APIs, the INSPIREHEP API does not require an account or API keys for accessing its public data. The core functionality, which includes searching for literature, authors, and other public-facing information, is freely accessible to all users without any authentication mechanism. This design choice simplifies the onboarding process for developers and researchers who primarily need to retrieve publicly available information.

For operations that might involve submitting data or managing personal profiles (which are typically handled through the INSPIREHEP web interface rather than the public API), specific web-based authentication methods would apply, but these fall outside the scope of general API data retrieval. Therefore, developers can proceed directly to making requests without needing to register or generate credentials.

This approach aligns with the open science principles often found in academic and research APIs, prioritizing broad accessibility to scientific data. For developers familiar with API platforms that mandate API key registration, this distinction simplifies the setup considerably, allowing immediate interaction with the service.

Quick Start Reference
Step What to Do Where
1. Understand Access Confirm no API key is required for public data. INSPIREHEP API documentation
2. Identify Endpoint Choose a relevant endpoint (e.g., literature search). INSPIREHEP API reference
3. Formulate Request Construct an HTTP GET request with necessary query parameters. Local development environment
4. Execute Request Use a tool like curl or a programming language's HTTP client. Terminal or IDE
5. Parse Response Process the JSON output to extract desired data. Local development environment

Your first request

To make your first request to the INSPIREHEP API, you will query the literature endpoint to retrieve information about scientific papers. This example will demonstrate how to search for papers by a specific author and receive a JSON-formatted response.

1. Choose an endpoint

The primary endpoint for literature searches is /api/literature. You can find more details on this and other available endpoints in the INSPIREHEP API documentation.

2. Formulate the query

To search for literature, you typically use the q parameter for your search query. For instance, to search for papers by an author named "Albert Einstein", your query might look like q=author:"Albert Einstein". You can also specify other fields like title, doctype, or year. The API supports various query syntaxes, similar to the main INSPIREHEP search functionality.

3. Construct the URL

Combine the base URL, endpoint, and query parameters. A complete URL for searching literature by Albert Einstein would be:

https://inspirehep.net/api/literature?q=author:%22Albert%20Einstein%22

Note that spaces and special characters in query parameters should be URL-encoded to ensure the request is correctly interpreted. In this example, "Albert Einstein" becomes %22Albert%20Einstein%22.

4. Execute the request

You can use command-line tools like curl to make HTTP requests, or integrate the request into your application using a programming language's HTTP client library.

Using curl:

curl -X GET "https://inspirehep.net/api/literature?q=author:%22Albert%20Einstein%22"

Using Python with the requests library:

import requests
import json

url = "https://inspirehep.net/api/literature"
params = {
    "q": "author:\"Albert Einstein\""
}

response = requests.get(url, params=params)

if response.status_code == 200:
    data = response.json()
    # Process the data
    print(json.dumps(data, indent=2))
else:
    print(f"Error: {response.status_code}")
    print(response.text)

5. Interpret the response

The API will return a JSON object containing the search results. A typical successful response (status code 200 OK) will include a hits object with an array of hits, each representing a document. Each document will contain metadata such as title, authors, publication_info, and a unique control_number.

Example (abbreviated):

{
  "hits": {
    "hits": [
      {
        "control_number": 1099190,
        "metadata": {
          "publication_info": [
            {
              "journal_title": "Phys.Rev.Lett.",
              "artid": "104001",
              "year": 2011,
              "volume": "106"
            }
          ],
          "titles": [
            {
              "title": "Quantum Gravity and the Standard Model"
            }
          ],
          "authors": [
            {
              "full_name": "Einstein, Albert"
            }
          ]
        },
        "links": {
          "self": "https://inspirehep.net/api/literature/1099190"
        }
      }
    ],
    "total": 1,
    "max_score": 1.0
  },
  "links": {
    "self": "https://inspirehep.net/api/literature?q=author%3A%22Albert+Einstein%22&page=1&size=25"
  }
}

In this example, the response indicates one hit for a paper titled "Quantum Gravity and the Standard Model" by Albert Einstein, published in Physical Review Letters.

Common next steps

After successfully making your first request, several avenues can be explored to deepen your integration with the INSPIREHEP API:

  • Explore other endpoints: Beyond literature, the API offers endpoints for authors (/api/authors), conferences (/api/conferences), institutions (/api/institutions), and jobs (/api/jobs). Each provides structured data relevant to high energy physics research. Consult the INSPIREHEP API documentation for a complete list and their specific query parameters.
  • Advanced querying: Learn to use more complex search queries. The API supports boolean operators (AND, OR, NOT), field-specific searches, and range queries. This allows for precise filtering of results, such as "papers published between 2010 and 2020 by a specific author" or "arxiv preprints on quantum computing".
  • Pagination and sorting: Implement pagination using the page and size parameters to retrieve large datasets efficiently. For example, &page=2&size=50 would fetch the second set of 50 results. You can also sort results by various fields like publication date or citation count using the sort parameter.
  • Error handling: Implement robust error handling in your application. The API returns standard HTTP status codes (e.g., 400 Bad Request for invalid queries, 404 Not Found for non-existent resources). Parsing these error responses will help your application gracefully manage issues.
  • Integrate into applications: Begin integrating the retrieved data into your specific application use case, whether it's building a custom research dashboard, an automated citation tracker, or a job alert system for physics positions.

Troubleshooting the first call

When encountering issues with your initial API calls to INSPIREHEP, consider the following common problems and their solutions:

  • Incorrect URL or endpoint: Double-check the base URL (https://inspirehep.net) and the specific endpoint (e.g., /api/literature). Minor typos can prevent a successful connection. Refer to the official API reference for exact paths.
  • URL encoding issues: Ensure that all special characters, spaces, and reserved characters within your query parameters are correctly URL-encoded. For example, a space should be %20 or a +, and a double quote " should be %22. Incorrect encoding often leads to 400 Bad Request errors or unexpected search results. Tools like Postman or programming language HTTP libraries usually handle this automatically, but manual construction requires attention to detail. Refer to MDN Web Docs on URL encoding for guidelines.
  • Network connectivity: Verify that your environment has internet access and is not blocked by a firewall or proxy that would prevent outgoing HTTP requests to inspirehep.net. A simple test like pinging the domain or accessing the homepage in a browser can confirm basic connectivity.
  • Invalid query parameters: If your request returns a 400 Bad Request, review your query parameters. Ensure that the field names (e.g., q for query, author, title) are correct and that the values comply with the expected format. The INSPIREHEP API's query language is powerful but requires adherence to its syntax.
  • JSON parsing errors: If you receive a response but your application fails to parse it, ensure that the response is indeed valid JSON. While the INSPIREHEP API primarily returns JSON, malformed responses due to server errors or network interruptions can occur. Use a JSON validator or print the raw response to inspect its structure.
  • Rate limiting: While the INSPIREHEP API is generous with public access, excessive requests in a short period might lead to temporary rate limiting. If you observe 429 Too Many Requests errors, pause your requests and retry after a brief interval. For higher volume needs, consider spacing out your calls.