REST APIs

To start with, we import the following:

from accern import API

Create API Instance

Create an API instance

Client = API()

Authenticate REST API Client

Authenticate your account when using the API token. Pass it into the REST Client and the library will pass it to every request. An API request without a token will fail.

Your API tokens carry many privileges. Don’t share your secret API tokens in any public spaces like Github, client-side code, etc.

To authenticate, pass it through the constructor or assign your YOUR TOKEN to the API instance.

token = 'YOUR TOKEN'
Client = API(token)

or

token = 'YOUR TOKEN'
Client.token = token

If token is not passed or invalid, an AuthenticateError will be raised

Request Data

The request method will send a GET request to retrieve data. The response will be the most recent 100 documents.

response = Client.request()

A response example.

{
    "first_id": 2714394,
    "last_id": 2742321,
    "total": 100,
    "signals": [
        {
            "id": 2742321,
            "signal_id": "3c78ab00-c751-4e37-8e16-669bad2c7135",
            "story_id": "5a283895a656f23864041346",
            "new_story_group": false,
            "overall_author_republish_score": "0.0",
            "overall_author_timeliness_score": "2.6805",
            "overall_source_republish_score": "0.0",
            "overall_source_timeliness_score": "2.5707",
            "story_group_sentiment_avg": "16.8",
            "story_group_sentiment_stdev": "27.1",
            "story_sentiment": null,
            "templated_story_score": null,
            "author_id": 1265989,
            "source_id": 22210,
            "story_group_count": 4,
            "story_group_traffic_sum": 395006047,
            "story_traffic": 939796,
            "story_group_exposure": "high",
            "story_group_id": "e956870a-10a6-45f7-b6c1-aca6f9425886",
            "story_source": "bloog.pl",
            "story_type": "blog",
            "harvested_at": "2017-12-06T18:36:13.007Z",
            "entity_sentiment": null,
            "event_sentiment": null,
            "entity_name": "Apple Inc.",
            "entity_ticker": "AAPL",
            "entity_exchange": "NASDAQ",
            "entity_relevance": "100.0",
            "entity_country": "United States",
            "entity_indices": [
                "S&P 500",
                "Russell 1000",
                "Russell 3000",
                "Wilshire 5000",
                "BARRON'S 400",
                "NASDAQ 100"
            ],
            "entity_industry": "Computer Manufacturing",
            "entity_region": "North America",
            "entity_sector": "Technology",
            "entity_competitors": [
                "005930",
                "005935",
                "6758",
                "2357",
                "HPQ",
                "MSFT",
                "IBM",
                "CSCO",
                "NOKIA",
                "MSI"
            ],
            "entity_type": "US_EQUITY",
            "entity_composite_figi": "BBG000B9XRY4",
            "entity_exch_code": "UW",
            "entity_figi": "BBG000B9Y5X2",
            "entity_market_sector": "Equity",
            "entity_security_description": "AAPL",
            "entity_security_type": "Common Stock",
            "entity_share_class_figi": "BBG001S5N8V8",
            "entity_unique_id": "EQ0010169500001000",
            "entity_unique_id_fut_opt": null,
            "entity_author_republish_score": "0.0",
            "entity_author_timeliness_score": "0.01",
            "entity_source_republish_score": "0.0",
            "entity_source_timeliness_score": "0.009",
            "event": "Product Development - General",
            "event_group": "Product Development",
            "event_relevance": "100.0",
            "event_author_republish_score": "0.0013",
            "event_author_timeliness_score": "42.7356",
            "event_source_republish_score": "0.0013",
            "event_source_timeliness_score": "42.6185",
            "event_impact_pct_change_avg": "0.0073",
            "event_impact_pct_change_stdev": "0.0715",
            "event_impact_pos": "55.9012",
            "event_impact_neg": "44.0988",
            "event_impact_gt_mu_add_sigma": "0.0915",
            "event_impact_lt_mu_sub_sigma": "0.0",
            "event_impact_gt_mu_pos_add_sigma_pos": "0.0",
            "event_impact_lt_mu_neg_sub_sigma_neg": "0.0",
            "event_impact_gt_mu_pos_add_2sigma_pos": "0.0",
            "event_impact_lt_mu_neg_sub_2sigma_neg": "0.0",
            "event_impact_gt_1pct_pos": "5.3065",
            "event_impact_lt_1pct_neg": "3.2022"
        },
        ...
    ]
}

To select only a few fields or filter some fields, build your schema and pass it to the function.

schema = {
    'select': [
        {
            'field': 'entity_ticker',
            'alias': 'ticker'
        }
    ]
}

response = Client.request(schema)