The REST API for OpenCitations Meta
Version: Version 1.1.1 (2022-12-22)
API URL: https://api.opencitations.net/meta/v1
Contact: contact@opencitations.net
License: This document is licensed with a Creative Commons Attribution 4.0 International License, while the REST API itself has been created using RAMOSE, the Restful API Manager Over SPARQL Endpoints created by Silvio Peroni, which is licensed with an ISC license.
Description back to top
This is the REST API for OpenCitations Meta, the OpenCitations dataset containing bibliographic metadata associated with the documents involved in the citations stored in the OpenCitations Indexes. All the present operations return either a JSON document (default) or a CSV document according to the mimetype specified in the Accept header of the request. If you would like to suggest an additional operation to be included in this API, please use the issue tracker of the OpenCitations APIs available on GitHub.
API calls are rate-limited to 180 requests/minute per IP address to ensure fair usage and service availability. For large-scale data retrieval, please use the database dumps available at download.opencitations.net.
If you are going to use the REST APIs within an application/code, we encourage you to get the OpenCitations Access Token and specify it in the "authorization" header of your REST API call. Here is a usage example in Python:
from requests import get
API_CALL = "https://api.opencitations.net/meta/v1/metadata/doi:10.1007/978-1-4020-9632-7"
HTTP_HEADERS = {"authorization": "YOUR-OPENCITATIONS-ACCESS-TOKEN"}
get(API_CALL, headers=HTTP_HEADERS)
Parameters back to top
Parameters can be used to filter and control the results returned by the API. They are passed as normal HTTP parameters in the URL of the call. They are:
-
require=<field_name>: all the rows that have an empty value in the<field_name>specified are removed from the result set - e.g.require=given_nameremoves all the rows that do not have any string specified in thegiven_namefield. -
filter=<field_name>:<operator><value>: only the rows compliant with<value>are kept in the result set. The parameter<operation>is not mandatory. If<operation>is not specified,<value>is interpreted as a regular expression, otherwise it is compared by means of the specified operation. Possible operators are "=", "<", and ">". For instance,filter=title:semantics?returns all the rows that contain the string "semantic" or "semantics" in the fieldtitle, whilefilter=date:>2016-05returns all the rows that have adategreater than May 2016. -
sort=<order>(<field_name>): sort in ascending (<order>set to "asc") or descending (<order>set to "desc") order the rows in the result set according to the values in<field_name>. For instance,sort=desc(date)sorts all the rows according to the value specified in the fielddatein descending order. -
format=<format_type>: the final table is returned in the format specified in<format_type>that can be either "csv" or "json" - e.g.format=csvreturns the final table in CSV format. This parameter has higher priority of the type specified through the "Accept" header of the request. Thus, if the header of a request to the API specifiesAccept: text/csvand the URL of such request includesformat=json, the final table is returned in JSON. -
json=<operation_type>("<separator>",<field>,<new_field_1>,<new_field_2>,...): in case a JSON format is requested in return, tranform each row of the final JSON table according to the rule specified. If<operation_type>is set to "array", the string value associated to the field name<field>is converted into an array by splitting the various textual parts by means of<separator>. For instance, considering the JSON table[ { "names": "Doe, John; Doe, Jane" }, ... ], the execution ofarray("; ",names)returns[ { "names": [ "Doe, John", "Doe, Jane" ], ... ]. Instead, if<operation_type>is set to "dict", the string value associated to the field name<field>is converted into a dictionary by splitting the various textual parts by means of<separator>and by associating the new fields<new_field_1>,<new_field_2>, etc., to these new parts. For instance, considering the JSON table[ { "name": "Doe, John" }, ... ], the execution ofdict(", ",name,fname,gname)returns[ { "name": { "fname": "Doe", "gname": "John" }, ... ].
It is possible to specify one or more filtering operation of the same kind (e.g. require=given_name&require=family_name). In addition, these filtering operations are applied in the order presented above - first all the require operation, then all the filter operations followed by all the sort operation, and finally the format and the json operation (if applicable). It is worth mentioning that each of the aforementioned rules is applied in order, and it works on the structure returned after the execution of the previous rule.
Example: <api_operation_url>?require=doi&filter=date:>2015&sort=desc(date).