CryptoInfo

FREEMIUM
By 1EX | Updated 2달 전 | Financial
Popularity

0.4 / 10

Latency

112ms

Service Level

0%

Health Check

N/A

Back to All Tutorials (2)

Analytical request example

Where is

Full tutorial
Notebook for this tutorial
Google Colab for this tutorial

Analyze news over a period of time

This query returns statistical data on news for a certain period of time using the specified filters.
You can test the request using the following Python code. When testing these requests through the built-in RapidAPI system, we had problems. Either the service did not respond, or code 307 was returned (we have nginx as a load balancer) without the ability to redirect the request. If you have similar difficulties with testing the API, try subscribing to the basic version and testing this code in person.

import requests

url = "https://cryptoinfo.p.rapidapi.com/api/private/news_over_a_period_of_time_analyze"

payload = {
	"time_start": "2023-01-20 17:34:58+00:00",
	"time_finish": "2023-01-23 17:34:58+00:00",
	"fields_to_search": ["crypto"],
	"tickers_to_search": ["BTC"],
	"hashtags_to_search": ["#Crypto"],
	"is_unique": 1,
	"is_appropriate": 1,
	"discretize_period": 1
}
headers = {
	"content-type": "application/json",
	"Accept": "application/json",
	"X-RapidAPI-Key": X_RAPIDAPI_KEY,
	"X-RapidAPI-Host": "cryptoinfo.p.rapidapi.com"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.status_code)

Request overview

  • time start and time finish is boundary time of news to get analysis. It should be in format: %Y-%m-%d %H:%M:%S%z
  • fields_to_search ([‘crypto’]) – first level keys in fields_tickers field in news data. fields_to_search can be: crypto, resources, fx, american, russian, token_sale. You can add some of them as a list, or comment this string, by default all news will be used. It searches for news, that include fields_to_search in fields_tickers
  • tickers_to_search ([‘BTC’]) – values for keys in fields_tickers field in news data. tickers_to_search can be chosen from file: tickers_to_search.xlsx in this directory. You can add some of them as a list or comment this string, by default all news will be used. It searches for news, that includes tickers_to_search in fields_tickers values
  • hashtags_to_search ([’#Crypto’]) – find news by hashtags in hashtags_list news field. hashtags_to_search can be chosen from file: hashtags_to_search.xlsx in this directory (And you need to convert your search string for # + first symbol uppercase). You can add some of them as a list or comment this string, by default all news will be used.
  • is_unique (1) – find only unique news (1); find only ununique news (-1); find both (0)
  • is_appropriate (1) – search for news that can be published according to our block-words settings (1); search for news that can’t be published (-1); search for both (0)
  • discretize_period (1) – discretization step of time period from time_start to time_finish, in hours. It can be only int >= 1

Response overview

  • Result of this analytical endpoint consists of two fields: dict_keys([‘aggregated’, ‘discretized’])
  • aggregated – all news statistics calculated for the whole time range
  • discretized – news statistics calculated in time windows with size discretize_period

Aggregated

Discretized

  • It consists of dict with different keys, that represents time ranges. Each element has the same structure as aggregated field. But also there are two keys that responsible for start and finish of time period: range_start and range_finish
  • First time range has key 0. range start: 2023-01-20 17:00:00+00:00 and range finish: 2023-01-20 18:00:00+00:00
  • Last time range has key 72 in this example. range start: 2023-01-23 17:00:00+00:00 and range finish: 2023-01-23 18:00:00+00:00
  • Important point. We round up the range_start and range_finish for the first and the last periods. If you make a retieval, as in this example, not in 17:00:00, your data will start from 17:34:58, but time range will be set to 17:00. Likewise for time_finish of retrieval, there is upper rounding. This is suitable for graphics plotting

Optional

If you don’t want to use fields_to_search, tickers_to_search, hashtags_to_search filters, you can simply comment it out in your request

payload = {
	"time_start": "2023-01-20 17:34:58+00:00",
	"time_finish": "2023-01-23 17:34:58+00:00",
	#"fields_to_search": ["crypto"],
	#"tickers_to_search": ["BTC"],
	#"hashtags_to_search": ["#Crypto"],
	"is_unique": 1,
	"is_appropriate": 1,
	"discretize_period": 1
}