Scribe Corporate Intelligence API
GraphQL API documentation for Scribe's Corporate Intelligence platform.
Authentication
Python
See https://pypi.org/project/scribeauth/ for the instructions on how to get a token.
Node.js
See https://www.npmjs.com/package/@scribelabsai/auth or
npm install @scribelabsai/auth
Raw API calls
Most calls to Scribe's API require authentication and authorization. This guide details the steps to follow.
You first need a Scribe account and a client ID. Both can be requested at support[atsign]scribelabs[dotsign]ai or through Intercom on https://platform.scribelabs.ai if you already have a Scribe account.
Flow
If you never have accessed your Scribe account, it probably still contains the temporary password we generated for you. You can change it directly on the platform or following these steps. You won't be able to access anything else until the temporary password has been changed.
Authenticating for the first time
- Getting challenge
Send a request with the following format:
curl -X POST https://cognito-idp.eu-west-2.amazonaws.com/ \
-H 'Content-Type: application/x-amz-json-1.1' \
-H 'X-Amz-Target: AWSCognitoIdentityProviderService.InitiateAuth' \
-d '{
"AuthFlow": "USER_PASSWORD_AUTH",
"ClientId": "{client_id}",
"AuthParameters": {
"USERNAME": "{username}",
"PASSWORD": "{password}"
}
}'
The response will look like this:
{
"ChallengeName": "NEW_PASSWORD_REQUIRED",
"Session": "string",
"ChallengeParameters": {
"string" : "string"
}
}
- Respond to challenge
Get Session and ChallengeParameters from the response. Get requiredAttributes and USER_ID_FOR_SRP from ChallengeParameters.
Send a request with the following format:
curl -X POST https://cognito-idp.eu-west-2.amazonaws.com/ \
-H 'Content-Type: application/x-amz-json-1.1' \
-H 'X-Amz-Target: AWSCognitoIdentityProviderService.RespondToAuthChallenge' \
-d '{
"ChallengeName": "NEW_PASSWORD_REQUIRED",
"ChallengeResponses": {
"USER_ID_FOR_SRP": "{user_id_for_srp}",
"requiredAttributes": "{required_attributes}",
"USERNAME": "{username}",
"NEW_PASSWORD": "{new_password}"
},
"ClientId": "{client_id}",
"Session": "{session}"
}'
The response will look like this:
{
"AuthenticationResult": {
"AccessToken": "string",
"ExpiresIn": number,
"IdToken": "string",
"NewDeviceMetadata": {
"DeviceGroupKey": "string",
"DeviceKey": "string"
},
"RefreshToken": "string",
"TokenType": "string"
},
"ChallengeName": "string",
"ChallengeParameters": {
"string" : "string"
},
"Session": "string"
}
Change Password
Send a request with the following format:
curl -X POST https://cognito-idp.eu-west-2.amazonaws.com/ \
-H 'Content-Type: application/x-amz-json-1.1' \
-H 'X-Amz-Target: AWSCognitoIdentityProviderService.ChangePassword' \
-d '{
"AccessToken": "{access_token}",
"PreviousPassword": "{old_password}",
"ProposedPassword": "{new_password}"
}'
Response:
If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.
Forgot Password
- Getting a confirmationCode
A message will be sent to the user email with a confirmation code that is required to change the user's password.
Send a request with the following format:
curl -X POST https://cognito-idp.eu-west-2.amazonaws.com/ \
-H 'Content-Type: application/x-amz-json-1.1' \
-H 'X-Amz-Target: AWSCognitoIdentityProviderService.ForgotPassword' \
-d '{
"ClientId": "{client_id}",
"Username": "{username}"
}'
The response will look like this:
{
"CodeDeliveryDetails": {
"AttributeName": "string",
"DeliveryMedium": "string",
"Destination": "string"
}
}
- Using confirmationCode
Send a request with the following format:
curl -X POST https://cognito-idp.eu-west-2.amazonaws.com/ \
-H 'Content-Type: application/x-amz-json-1.1' \
-H 'X-Amz-Target: AWSCognitoIdentityProviderService.ConfirmForgotPassword' \
-d '{
"ClientId": "{client_id}",
"Username": "{username}",
"ConfirmationCode": "{confirmation_code}",
"Password": "{new_password}"
}'
Response:
If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.
Get tokens
With username and password:
Send a request with the following format:
curl -X POST https://cognito-idp.eu-west-2.amazonaws.com/ \
-H 'Content-Type: application/x-amz-json-1.1' \
-H 'X-Amz-Target: AWSCognitoIdentityProviderService.InitiateAuth' \
-d '{
"AuthFlow": "USER_PASSWORD_AUTH",
"ClientId": "{client_id}",
"AuthParameters": {
"USERNAME": "{username}",
"PASSWORD": "{password}"
}
}'
The response will look like this:
{
"AuthenticationResult": {
"AccessToken": "string",
"ExpiresIn": number,
"IdToken": "string",
"NewDeviceMetadata": {
"DeviceGroupKey": "string",
"DeviceKey": "string"
},
"RefreshToken": "string",
"TokenType": "string"
},
"ChallengeName": "string",
"ChallengeParameters": {
"string" : "string"
},
"Session": "string"
}
With refreshToken:
Send a request with the following format:
curl -X POST https://cognito-idp.eu-west-2.amazonaws.com/ \
-H 'Content-Type: application/x-amz-json-1.1' \
-H 'X-Amz-Target: AWSCognitoIdentityProviderService.InitiateAuth' \
-d '{
"AuthFlow": "REFRESH_TOKEN",
"ClientId": "{client_id}",
"AuthParameters": {
"REFRESH_TOKEN": "{refresh_token}"
}
}'
The response will look like this:
{
"AuthenticationResult": {
"AccessToken": "string",
"ExpiresIn": number,
"IdToken": "string",
"NewDeviceMetadata": {
"DeviceGroupKey": "string",
"DeviceKey": "string"
},
"RefreshToken": "string",
"TokenType": "string"
},
"ChallengeName": "string",
"ChallengeParameters": {
"string" : "string"
},
"Session": "string"
}
Revoke Refresh Token
Send a request with the following format:
curl -X POST https://cognito-idp.eu-west-2.amazonaws.com/ \
-H 'Content-Type: application/x-amz-json-1.1' \
-H 'X-Amz-Target: AWSCognitoIdentityProviderService.RevokeToken' \
-d '{
"ClientId": "{client_id}",
"Token": "{refresh_token}"
}'
Response:
If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.
Possible Exceptions
InternalErrorException
This exception is thrown when Amazon Cognito encounters an internal error.
HTTP Status Code: 500
InvalidParameterException
This exception is thrown when the Amazon Cognito service encounters an invalid parameter.
HTTP Status Code: 400
TooManyRequestsException
This exception is thrown when the user has made too many requests for a given operation. For example: Changing passwords frequently within a short time period.
HTTP Status Code: 400
UnauthorizedException
Exception that is thrown when the request isn't authorized.
HTTP Status Code: 400
Once you have the
id token, use it as an
Authorization header, i.e. "Authorization": "token"
Queries
companiesByName
Description
Get up to limit companies by name start, with up to flimit years of financials
Response
Returns
[Company!]
Example
Query
query companiesByName(
$name: String!,
$limit: Int!,
$flimit: Int
) {
companiesByName(
name: $name,
limit: $limit,
flimit: $flimit
) {
id
companyid
name
companyname
country
industry
siccode
currency
location
companylocation
county
postcode
creationdate
companytype
previousname
lastreported
lastmadeupdate
nextduedate
cessationdate
financialmodel {
period
isrevenueapprox
inc {
...StandardIncomeStatementFragment
}
bst {
...StandardBalanceSheetFragment
}
cfl {
...StandardCashFlowFragment
}
}
}
}
Variables
{"name": "TESTCO", "limit": 1, "flimit": 5}
Response
{
"data": {
"companiesByName": [
{
"id": "UK12345678",
"companyid": "UK12345678",
"name": "TESTCO LIMITED",
"companyname": "TESTCO LIMITED",
"country": "UK",
"industry": 10,
"siccode": 62020,
"currency": "GBP",
"location": "London",
"companylocation": "London",
"county": "Greater London",
"postcode": "E1 6AN",
"creationdate": "2020-01-01",
"companytype": "Private Limited Company",
"previousname": "PREVIOUS NAME LIMITED",
"lastreported": "2020-01-01",
"lastmadeupdate": "2020-01-01",
"nextduedate": "2020-01-01",
"cessationdate": "2020-01-01",
"financialmodel": [StandardFinancials]
}
]
}
}
companiesWithFilters
Description
Get up to limit companies with filters, with up to flimit years of financials
Response
Returns
[Company!]!
Arguments
Name | Description |
---|---|
anchor -
ID
|
Optional company used as anchor point for the filter query. Will return companies similar to this one matching the filters. Needs to start with UK for UK companies. |
filters -
[Filter!]
|
Filters to apply |
limit -
Int!
|
Maximum number of companies to return |
offset -
Int
|
Number of companies to skip, for pagination |
sortBy -
String
|
Sort companies before returning them, useful when limiting |
order -
String
|
Direction of sorting, use with sortBy Authorised values: asc, desc |
flimit -
Int
|
Default = 0 |
Example
Query
query companiesWithFilters(
$anchor: ID,
$filters: [Filter!],
$limit: Int!,
$offset: Int,
$sortBy: String,
$order: String,
$flimit: Int
) {
companiesWithFilters(
anchor: $anchor,
filters: $filters,
limit: $limit,
offset: $offset,
sortBy: $sortBy,
order: $order,
flimit: $flimit
) {
id
companyid
name
companyname
country
industry
siccode
currency
location
companylocation
county
postcode
creationdate
companytype
previousname
lastreported
lastmadeupdate
nextduedate
cessationdate
financialmodel {
period
isrevenueapprox
inc {
...StandardIncomeStatementFragment
}
bst {
...StandardBalanceSheetFragment
}
cfl {
...StandardCashFlowFragment
}
}
}
}
Variables
{
"anchor": "UK12345678",
"filters": [Filter],
"limit": 1,
"offset": 20,
"sortBy": "inc.increv",
"order": "desc",
"flimit": 5
}
Response
{
"data": {
"companiesWithFilters": [
{
"id": "UK12345678",
"companyid": "UK12345678",
"name": "TESTCO LIMITED",
"companyname": "TESTCO LIMITED",
"country": "UK",
"industry": 10,
"siccode": 62020,
"currency": "GBP",
"location": "London",
"companylocation": "London",
"county": "Greater London",
"postcode": "E1 6AN",
"creationdate": "2020-01-01",
"companytype": "Private Limited Company",
"previousname": "PREVIOUS NAME LIMITED",
"lastreported": "2020-01-01",
"lastmadeupdate": "2020-01-01",
"nextduedate": "2020-01-01",
"cessationdate": "2020-01-01",
"financialmodel": [StandardFinancials]
}
]
}
}
company
Description
Get a single company and up to flimit years of financials
Response
Returns a
Company
Example
Query
query company(
$id: ID!,
$flimit: Int
) {
company(
id: $id,
flimit: $flimit
) {
id
companyid
name
companyname
country
industry
siccode
currency
location
companylocation
county
postcode
creationdate
companytype
previousname
lastreported
lastmadeupdate
nextduedate
cessationdate
financialmodel {
period
isrevenueapprox
inc {
...StandardIncomeStatementFragment
}
bst {
...StandardBalanceSheetFragment
}
cfl {
...StandardCashFlowFragment
}
}
}
}
Variables
{"id": "UK12345678", "flimit": 5}
Response
{
"data": {
"company": {
"id": "UK12345678",
"companyid": "UK12345678",
"name": "TESTCO LIMITED",
"companyname": "TESTCO LIMITED",
"country": "UK",
"industry": 10,
"siccode": 62020,
"currency": "GBP",
"location": "London",
"companylocation": "London",
"county": "Greater London",
"postcode": "E1 6AN",
"creationdate": "2020-01-01",
"companytype": "Private Limited Company",
"previousname": "PREVIOUS NAME LIMITED",
"lastreported": "2020-01-01",
"lastmadeupdate": "2020-01-01",
"nextduedate": "2020-01-01",
"cessationdate": "2020-01-01",
"financialmodel": [StandardFinancials]
}
}
}
Types
Boolean
Description
The Boolean
scalar type represents true
or false
.
BooleanFilter
Company
Description
Company Profile
Fields
Field Name | Description |
---|---|
id -
ID!
|
Companies House company number prepended with UK for UK companies |
companyid -
ID!
|
Companies House company number prepended with UK for UK companies
Deprecated see |
name -
String!
|
Name of the company |
companyname -
String!
|
Name of the company
Deprecated see |
country -
String!
|
Country this company is registered in |
industry -
Int!
|
Scribe industry classification |
siccode -
Int!
|
Original SIC Code |
currency -
String!
|
Currency the financials are reported in |
location -
String!
|
City/town |
companylocation -
String!
|
City/town
Deprecated see |
county -
String!
|
County |
postcode -
String!
|
Postcode |
creationdate -
String!
|
Creation date |
companytype -
String!
|
Type of the company as defined by Companies House |
previousname -
String
|
Previous name if the company has changed |
lastreported -
String
|
Date of the last report (publication date) |
lastmadeupdate -
String
|
Date of the last report (made up date) |
nextduedate -
String
|
Date next accounts are due |
cessationdate -
String
|
Date of dissolution |
financialmodel -
[StandardFinancials!]
|
Financial model |
Example
{
"id": "UK12345678",
"companyid": "UK12345678",
"name": "TESTCO LIMITED",
"companyname": "TESTCO LIMITED",
"country": "UK",
"industry": 10,
"siccode": 62020,
"currency": "GBP",
"location": "London",
"companylocation": "London",
"county": "Greater London",
"postcode": "E1 6AN",
"creationdate": "2020-01-01",
"companytype": "Private Limited Company",
"previousname": "PREVIOUS NAME LIMITED",
"lastreported": "2020-01-01",
"lastmadeupdate": "2020-01-01",
"nextduedate": "2020-01-01",
"cessationdate": "2020-01-01",
"financialmodel": [StandardFinancials]
}
Filter
Description
Filter on a single field. Must have exactly one of text, number, boolean
Fields
Input Field | Description |
---|---|
tag -
String!
|
Scribe tag for the item to filter by |
type -
String!
|
Type of the item (inc, bst, cfl, profile) |
text -
TextFilter
|
Text filter (exclusive with number and boolean filter) |
number -
NumberFilter
|
Number filter (exclusive with text and boolean filter) |
boolean -
BooleanFilter
|
Boolean filter (exclusive with text and number filters) |
Example
{
"tag": "increv",
"type": "inc",
"text": TextFilter,
"number": NumberFilter,
"boolean": BooleanFilter
}
ID
Description
The ID
scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as "4"
) or integer (such as 4
) input value will be accepted as an ID.
Example
4
Int
Description
The Int
scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.
Example
123
Long
Example
{}
NumberFilter
Description
Filter on number fields (e.g. revenue).
All filters are mutually exclusive for a given field.
Example
{"equals": 100000, "above": 100000, "below": 100000, "between": ["10", "1000"]}
StandardBalanceSheet
Description
Balance sheet
Fields
Field Name | Description |
---|---|
cacash -
Long
|
Cash & cash equivalents |
cainv -
Long
|
Stock |
cadebtor -
Long
|
Debtors |
catca -
Long
|
Total current assets |
ncattang -
Long
|
Tangible assets |
ncaint -
Long
|
Non-tangible assets |
ncatnca -
Long
|
Total non-current assets |
ta -
Long
|
Total assets |
clcred -
Long
|
Creditors |
clstdebt -
Long
|
Short-term debt |
tcl -
Long
|
Total current liabilities |
nclcredit -
Long
|
Creditors |
ncldebt -
Long
|
Long-term debt |
tncl -
Long
|
Total non-current liabilities |
tl -
Long
|
Total liabilities |
eqcap -
Long
|
Share capital |
eqte -
Long
|
Total equity |
Example
{
"cacash": 100000,
"cainv": 100000,
"cadebtor": 100000,
"catca": 100000,
"ncattang": 100000,
"ncaint": 100000,
"ncatnca": 100000,
"ta": 100000,
"clcred": 100000,
"clstdebt": 100000,
"tcl": 100000,
"nclcredit": 100000,
"ncldebt": 100000,
"tncl": 100000,
"tl": 100000,
"eqcap": 100000,
"eqte": 100000
}
StandardCashFlow
Description
Cash-flow statement
Fields
Field Name | Description |
---|---|
opintpaid -
Long
|
Interest paid |
optax -
Long
|
Tax paid |
opnetcf -
Long
|
Operating cash flow |
invprop -
Long
|
Capital expenditure |
invpropdisp -
Long
|
Sale of fixed assets |
invinvest -
Long
|
Investments |
invnetinvest -
Long
|
Investing cash flow |
finborrow -
Long
|
New loans |
finrepay -
Long
|
Loans repaid |
findivi -
Long
|
Dividends paid |
finnetfin -
Long
|
Financing cash flow |
cashopen -
Long
|
Opening cash |
cashclose -
Long
|
Closing cash |
cashinc -
Long
|
Net change in cash |
Example
{
"opintpaid": 100000,
"optax": 100000,
"opnetcf": 100000,
"invprop": 100000,
"invpropdisp": 100000,
"invinvest": 100000,
"invnetinvest": 100000,
"finborrow": 100000,
"finrepay": 100000,
"findivi": 100000,
"finnetfin": 100000,
"cashopen": 100000,
"cashclose": 100000,
"cashinc": 100000
}
StandardFinancials
Description
Financial model
Fields
Field Name | Description |
---|---|
period -
String!
|
Financial year |
isrevenueapprox -
Boolean!
|
Has Scribe approximated the revenues |
inc -
StandardIncomeStatement
|
Income statement (if available) for that financial year |
bst -
StandardBalanceSheet!
|
Balance sheet for that financial year |
cfl -
StandardCashFlow
|
Cash-flow statement (if available) for that financial year |
Example
{
"period": "FY2022",
"isrevenueapprox": true,
"inc": StandardIncomeStatement,
"bst": StandardBalanceSheet,
"cfl": StandardCashFlow
}
StandardIncomeStatement
Description
Income statement
Example
{
"increv": 100000,
"inccogs": 100000,
"incgrossprof": 100000,
"incopcostsadmin": 100000,
"incopprof": 100000,
"incnfc": 100000,
"pbt": 100000,
"incalltax": 100000,
"pat": 100000
}
String
Description
The String
scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
Example
"xyz789"
TextFilter
Description
Filter on text fields (e.g. name, industry).
All filters are mutually exclusive for a given field.
Fields
Input Field | Description |
---|---|
equals -
String
|
Exact match |
startsWith -
String
|
Match the beginning of the string |
in -
[String!]
|
Match any of the provided values |
between -
[String!]
|
Matches values in the given range (inclusive). Two values only. |
before -
String
|
Matches values before (or equal to) the given value |
after -
String
|
Matches values after (or equal to) the given value |
Example
{
"equals": "TESTCO LIMITED",
"startsWith": "TESTCO",
"in": ["Construction", "Information and communication > IT Service"],
"between": ["a", "d"],
"before": "m",
"after": "i"
}