Get started with OSO API
The OSO API serves queries on metrics and metadata about open source projects. It is a GraphQL API backed by the OSO data pipeline.
Let's make your first query in under five minutes.
Generate an API key
First, go to www.opensource.observer and create a new account.
If you already have an account, log in. Then create a new personal API key:
- Go to Account settings
- In the "API Keys" section, click "+ New"
- Give your key a label - this is just for you, usually to describe a key's purpose.
- You should see your brand new key. Immediately save this value, as you'll never see it again after refreshing the page.
- Click "Create" to save the key.
Prepare your query
You can navigate to our public GraphQL explorer to explore the schema and execute test queries.
For example, this query will fetch the first 10 projects in oss-directory.
query GetProjects {
oso_projectsV1(limit: 10) {
description
displayName
projectId
projectName
projectNamespace
projectSource
}
}
Issue your first API request
All API requests are sent to the following URL:
https://www.opensource.observer/api/v1/graphql
In order to authenticate with the API service, you have to use the Authorization
HTTP header and Bearer
authentication on all HTTP requests
- curl
- JavaScript
- Python
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DEVELOPER_API_KEY" \
-d '{"query":"query GetProjects { oso_projectsV1(limit: 10) { description displayName projectId projectName projectNamespace projectSource } }"}' \
https://www.opensource.observer/api/v1/graphql
const query = `
query GetProjects {
oso_projectsV1(limit: 10) {
description
displayName
projectId
projectName
projectNamespace
projectSource
}
}
`;
const headers = {
'Content-Type': 'application/json',
'Authorization': `Bearer ${DEVELOPER_API_KEY}`,
};
const response = await fetch('https://www.opensource.observer/api/v1/graphql', {
method: 'POST',
headers: headers,
body: JSON.stringify({
query: query
}),
});
const data = await response.json();
console.log(data);
import requests
query = """
query GetProjects {
oso_projectsV1(limit: 10) {
description
displayName
projectId
projectName
projectNamespace
projectSource
}
}
"""
headers = {
'Content-Type': 'application/json',
'Authorization': f'Bearer {DEVELOPER_API_KEY}'
}
response = requests.post(
'https://www.opensource.observer/api/v1/graphql',
json={'query': query},
headers=headers
)
data = response.json()
print(data)
Next steps
Congratulations! You've made your first API request. Now try one of our tutorials.