2024-07-10 20:22:13 +02:00
# Making requests
2024-07-11 18:56:14 +02:00
This guide provides examples of how to make requests to the OpenAIRE Graph API using different programming languages.
2024-07-10 20:22:13 +02:00
2024-07-11 18:56:14 +02:00
## Using `curl`
2024-07-10 20:22:13 +02:00
```bash
2024-07-11 18:56:14 +02:00
curl -X GET "https://api-beta.openaire.eu/graph/researchProducts?search=OpenAIRE%20Graph& type=publication& page=1& pageSize=10& sortBy=relevance%20DESC" -H "accept: application/json"
2024-07-10 20:22:13 +02:00
```
2024-07-11 18:56:14 +02:00
## Using Python (with `requests` library)
2024-07-10 20:22:13 +02:00
```python
import requests
2024-07-11 18:56:14 +02:00
url = "https://api-beta.openaire.eu/graph/researchProducts"
params = {
"search": "OpenAIRE Graph",
"type": "publication",
"page": 1,
"pageSize": 10,
"sortBy": "relevance DESC"
}
2024-07-10 20:22:13 +02:00
headers = {
"accept": "application/json"
}
2024-07-11 18:56:14 +02:00
response = requests.get(url, headers=headers, params=params)
2024-07-10 20:22:13 +02:00
if response.status_code == 200:
2024-07-11 18:56:14 +02:00
data = response.json()
print(data)
2024-07-10 20:22:13 +02:00
else:
2024-07-11 18:56:14 +02:00
print(f"Failed to retrieve data: {response.status_code}")
2024-07-10 20:22:13 +02:00
```
2024-07-11 18:56:14 +02:00
:::note
Note that when using `curl` you should ensure that the URL is properly encoded, especially when using special characters or spaces in the query parameters. On the contrary, the `requests` library in Python takes care of URL encoding automatically.
:::