AlphaSense's API Documentation
Welcome to the API documentation for AlphaSense! You'll be set up and running in just a few steps. If you haven't yet, reach out to apisupport@alphasense.com to begin a trial.
Quick Start
- Authentication: Make a call to get an access (bearer) token.
- API Calls: Use the token from step 1 to initiate your API calls.
To make this easy, we've provided a library of queries and mutations within this portal. Here's what you need to do:
- Find the query you want to run in the documentation.
- Configure it using your API key and the bearer/refresh token (you'll get this from the authentication call).
- Start making your API calls.
You can use the code editor tabs to generate code snippets in many languages once you've made your API calls.
GraphQL API
We use GraphQL, so you can customize how much data you get with each call. If you've used REST before, don't worry! It's just as simple. Make a POST API call, place your GraphQL query in the body, and expect a JSON response.
- URLs for Saas Clients
- URLs for Private Cloud Clients
https://api.alpha-sense.com/auth # Authentication Endpoint
https://api.alpha-sense.com/gql # GraphQL Endpoint
https://research.alpha-sense.com/services/i/ingestion-api/v1/... # Ingestion Endpoint
https://{YOUR-DOMAIN}/auth # Authentication Endpoint
https://{YOUR-DOMAIN}/services/i/graphql-gateway-external # GraphQL Endpoint
https://{YOUR-DOMAIN}/services/i/ingestion-api/v1/... # Ingestion Endpoint
Examples for GraphQL APIs
All examples below are for the AlphaSense API Suite. For more information on the Ingestion API, please visit here.
- 1. Authentication Call
- 2. Search API Call
curl --location --request POST 'https://api.alpha-sense.com/auth'
--header 'x-api-key: <YOUR API KEY>'
--header 'Content-Type: application/x-www-form-urlencoded'
--data-urlencode 'grant_type=password'
--data-urlencode 'username=<YOUR AlphaSense LOGIN EMAIL>'
--data-urlencode 'password=<YOUR AlphaSense LOGIN PASSWORD>'
--data-urlencode 'client_id=<YOUR CLIENT ID>'
--data-urlencode 'client_secret=<YOUR CLIENT SECRET>'
curl --location --request POST 'https://api.alpha-sense.com/gql'
--header 'x-api-key: <YOUR API KEY>'
--header 'clientid: <YOUR CLIENT ID>'
--header 'Authorization: Bearer <YOUR ACCESS TOKEN>'
--header 'Content-Type: application/json'
--data-raw '{"query":"query sample_search {search(limit: 20 filter: { keyword: { query: "incentive structure"}date: { preset: LAST_30_DAYS } } sorting: { field: DATE direction: DESC }) { documents { id title releasedAt type {ids} } cursor }} ","variables":{}}'
GraphQL Primer
Two main pieces are passed into every GraphQL operation, the query and filter are the main things you need to get going. Craft your query by providing the inputs and outputs all in one section:
query sample_search {
search( # Inputs
limit: 20
filter: {
keyword: {
query: "incentive structure"
}
date: {
preset: LAST_30_DAYS
}
}
sorting: {
field: DATE
direction: DESC
}
){ # Outputs
documents {
id
title
releasedAt
type {
ids
}
}
cursor
}
}
Let's break this down into smaller chunks and abstract it to allow for more flexibility in declaring the variables. First write the query with the variables as paramaters:
query sample_search ($filter: SearchFilter!, $limit: Int!, $sorting: SearchSorting!){
search (filter: $filter, limit: $limit, sorting: $sorting){ # Outputs
documents {
id
title
releasedAt
type {
ids
}
}
cursor
}
}
Then write the parameters as a dictionary of variables:
{
limit: 20
filter: {
keyword: {
query: "incentive structure"
}
date: {
preset: LAST_30_DAYS
}
}ß
sorting: {
field: DATE
direction: DESC
}
}
Now you can pass the query and the variables in a POST request!
Further Reading
If you want to learn more about the different queries and mutations we have available click on some of the examples in the left side! If you want to further explore all the variables available in our schema, view the Explorer For more comprehensive understanding of GraphQL, please consult the dedicated page on GraphQL Best Practices. Additionally, make sure to review the FAQs page for additional information.