API Documentation
-
Getting
access to the API, authorization
The API is available at https://biopharma.pw/api
registered on the site
In order to access the API, you must be:
to get a token for authorization -
Getting
an authorization token
In order to get a token, you must send a POST request to https://biopharma.pw/api/auth/token/login/
Your request must contain a username and password, after that you will receive a token that gives you the right to access the API.In the following screenshots, using the example of the Postman program, you can see the sequence of actions to access the API:
The token is valid until you log out. The next time you log in, you will be assigned a new token.
-
Log
out of the system
In order to log out, you must send a POST request containing in the header "Authorization" your token to https://biopharma.pw/api/auth/token/logout/
After that, your token will be deleted, and a new token will be assigned to you at the next authorization.
-
Generating
requests to receive data from the Abiopharma API
# get the news with the headline "Novavax Inc (NVAX)"
https://biopharma.pw/api/?title=Novavax+Inc+(NVAX) or
https://biopharma.pw/api/?title=Novavax Inc (NVAX)
# get News with headline containing case insensitive "pharmaceuticals"
https://biopharma.pw/api/?title__icontains=pharmaceuticals
# get News where headline does NOT contain "pharmaceuticals"
https://biopharma.pw/api/?title__icontains!=pharmaceuticals
# get News that is created after 2022-08-10
https://biopharma.pw/api/?created_at__gt=2022-08-10
# get News that is created after 2022-08-10
https://biopharma.pw/api/?created_at__gt=2022-08-10
# get news created before 2022-08-10
https://biopharma.pw/api/?created_at__lt=2022-08-10
# get News that is created between 2022-08-04 and 2022-08-07
https://biopharma.pw/api/?created_at__range=2022-08-04,2022-08-07
-
Generating
requests to receive data from the Abiopharma API by category
Our news is divided into categories, you can refer to a certain category as follows:
# get News with category id 2
https://biopharma.pw/api/?category=2
# get News with category id either 2, 3 or 5
https://biopharma.pw/api/?category__in=2,3,5
# get News with category id between 1 and 3
https://biopharma.pw/api/?category__range=1,3
The ratio of the names of news categories and their id:
category_id = 1 - "Event"
category_id = 2 - "Business News"
category_id = 3 - "SEC News"
category_id = 4 - "Company Report"
category_id = 5 - "FDA Approval" -
Generating
requests to get a list of companies from the Abiopharma API
You can also get a list of companies by contacting https://biopharma.pw/api/company_list/
When accessing the list of companies, the following parameters are available:
ticket
cmpn - company name
# get data about a company called "Graphite Bio Inc"
https://biopharma.pw/api/company_list/?cmpn=Graphite+Bio+Inc or
https://biopharma.pw/api/company_list/?cmpn=Graphite Bio Inc
# get data about a company whose name contains "Bio" case-insensitive
https://biopharma.pw/api/company_list/?cmpn__icontains=Bio
# get data about a company whose name does not contain "Inc"
https://biopharma.pw/api/company_list/?cmpn__icontains!=Inc
# get information about the company whose ticket is "ARQT"
https://biopharma.pw/api/company_list/?ticket=ARQT
# get data about a company whose ticket contains "UX" case-insensitive
https://biopharma.pw/api/company_list/?ticket__icontains=ux
# get data about a company whose ticket does not contain "CX" case-insensitive
https://biopharma.pw/api/company_list/?ticket__icontains!=cx
To get more accurate data, we recommend using more complex queries
# get data where the company name contains "ltd" and the ticket contains "cn"
https://biopharma.pw/api/company_list/?cmpn__icontains=ltd&ticket__icontains=cn
You can combine different query parameters with each other.
-
Creating
requests to the Abiopharma API to get information about company stock quotes
You can get information about stock quotes of companies from the list of available tickers using the following APIs
https://biopharma.pw/api/quote_ticker/To read the data, the following parameters are available to you:
ticker
datatime
To get a ticker request, you can use the following queries:
# get tickers with the "XNCR" header
https://biopharma.pw/api/quote_ticker/?ticker=XNCR
# get tickers with a header containing "cr" case-insensitive
https://biopharma.pw/api/quote_ticker/?ticker__icontains=cr
# get tickers whose header does NOT contain "cr"
https://biopharma.pw/api/quote_ticker/?ticker__icontains!=cr
# get tickers where datetime is greater than 2022-09-27 07:36:51
https://biopharma.pw/api/quote_ticker/?datetime__gt=2022-09-27T07:36:51
# get tickers where datetime is less than 2022-09-27 09:00:51
https://biopharma.pw/api/quote_ticker/?datetime__lt=2022-09-27T09:00:51
# get tickers created between 2022-09-27 08:45:00 and 2022-09-27 09:24:05
https://biopharma.pw/api/quote_ticker/?datetime__range=2022-09-27T08:45:00,2022-09-27T09:24:05
It is highly recommended to query data using two parameters: ticket and datetime. In case of use:
- only one ticket parameter will provide information on the specified ticket for the last day;
- only one datetime parameter will provide information for the last hour on all available tickets.
Restrictions are introduced to reduce the load.
To get a more accurate and detailed response to your request, we recommend using a complex query consisting of several parameters, then you will be able to get all the available records.
# get the data on the cations where the "JAZZ" ticker and datetime are in the range from 2022-09-23 to 2022-09-27
https://biopharma.pw/api/quote_ticker/?ticker=JAZZ&datetime__range=2022-09-23,2022-09-27 or
https://biopharma.pw/api/quote_ticker/?ticker=JAZZ&datetime__range=2022-09-23T10:00:01,2022-09-27T09:26:01
Attention, the list of tickers and companies is available at https://biopharma.pw/company_list/ or when
accessing the API https://biopharma.pw/api/company_list/ -
Creating requests to the
Biopharma API to get information about the full list of the NASDAQ/NYSE exchange
You can get information about the full list of the NASDAQ/NYSE exchange using the following APIs
https://biopharma.pw/api/get_exch_list/Value of data fields:
symbol -> Symbol
sec_name -> Security name
test_mode -> Test issue
fin_status -> Financial status
fin_status_description -> Вescription of financial status
exchange -> Exchange
industry -> Industry
# get data where symbol "FRG"
https://biopharma.pw/api/get_exch_list/?symbol=FRG
# get data where symbol contains "GFX" case-insensitive
https://biopharma.pw/api/get_exch_list/?symbol__icontains=gfx
# get data where symbol does not contain "GFX" case-insensitive
https://biopharma.pw/api/get_exch_list/?symbol__icontains!=gfx
These methods are available for the fields 'symbol', 'sec_name', 'test_mode', 'fin_status', 'exchange', 'industry'.
You can combine different query parameters with each other.
-
Pagination when receiving data
from the Abiopharma API
To optimize server operation and processing large amounts of data in response to requests to https://biopharma.pw/api/, the pagination system is enabled. This means that you will need to switch the pages of the query results by adding the page parameter with the page number to the query.
# Specifying the page number
https://biopharma.pw/api/?page=1
https://biopharma.pw/api/?page=2
https://biopharma.pw/api/?category=2&page=2
By default, 500 entries per page are set.
-
Sample
Python code for authorization and API connection
import requests
#r = requests.post("https://biopharma.pw/api/auth/token/login/", data={'username': '*****',
'password': '*****'})
r =
requests.get("https://biopharma.pw/api/quote_ticker/?ticket=XNCR&datetime__range=2022-09-20T00:02:02,2022-09-27T00:02:02",
headers={'Authorization': 'Token *****'})
print(r.status_code, r.reason, r.text)