Skip to main content

This is a package that helps clients access sustainalytics API

Project description

Introduction

Starting with sustainalytics 0.2.0, the package is compatible with API v2 only. If a v1-compatible version is needed, please install version 0.1.2 via this command:

pip install sustainalytics==0.1.2

This python package provides access to Sustainalytics API (Application Programming Interface) service which provides developers with 24x7 programmatic access to Sustainalytics data. The API has been developed based on market standards with a primary focus on secure connectivity and ease of use. It allows users to retrieve and integrate Sustainalytics data into their own internal systems and custom or third-party applications

This document is meant to provide developers with python sample code for the Sustainalytics API service. Technical documentation can also be found on the dedicated website for the API.

Figure1

Installation

Install the package via pip with code below:

pip install sustainalytics

To Upgrade:

pip install --upgrade sustainalytics

Connection

A clientid and a secret key must be provided by the Sustainalytics Team in order to access the API. See connection via python:

from sustainalytics.api import API

#Access
client_id = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
client_secret_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

con = API(client_id=client_id, client_secretkey=client_secret_key)

#returns Bearer
print(con.access_headers)

Endpoints

DataService

The DataService enables the user to call the research data associated with the companies in the universe of access. Within this service there are two endpoints, as described below.

The code below shows you how to extract data from these endpoints

GetData

Retrieves data from the DataService endpoint. 'identifiers' and 'productId' are mandatory endpoints

The 'identifiers' and 'productId' arguments can be combined with only one of the other arguments:

identifiers : A list of security or entity identifiers separated by comma. You can obtain list of EntityIds from the con.get_universe_entityIds(keep_duplicates=True)

packageIds : A list of package ids separated by comma. You can obtain list of PackageIds from the con.get_packageIds()

fieldClusterIds : A list of field cluster ids separated by comma. You can obtain list of FieldClusterIds from the con.get_fieldClusterIds()

fieldIds : A list of field ids separated by comma. You can obtain list of FieldIds from the con.get_fieldIds()

#### GetData
data = con.get_data(identifiers=[], productId=[], packageIds=[], fieldClusterIds=[], fieldIds=[])
#returns data for the specified identifier(s). 'identifiers' and 'productId' are required for the function to work.
print(data)

Product Structure & Definitions

Each product is built from data packages and each data package is built from field clusters. The datafields are the smallest components of the product structure.

The Product Structure service provides an overview of the data fields available in the Sustainalytics API and the unique FieldIds linked to each of these data fields. Within this service there are three endpoints, as described below.

Figure2

The code below shows you how to extract data from these endpoints

#### FieldDefinitions
field_definitions = con.get_fieldDefinitions(dtype='dataframe') #by default dtype='json'
print(field_definitions)

#### FieldMappings
field_mappings = con.get_fieldMappings(dtype='dataframe') #by default dtype='json'
print(field_mappings)

#### FieldMappingDefinitions
field_mapping_definition = con.get_fieldMappingDefinitions(dtype='dataframe') #by default dtype='json'
print(field_mapping_definition)

#### Extra FieldDefinition (non-Swagger)
fullFieldDef = con.get_fullFieldDefinitions(dtype='dataframe')
print(fullFieldDef)

Reports

The ReportService endpoint allows users to retrieve a list of all available PDF report types by ReportId, ReportType, and ReportName for companies belonging to the universe of access.

(Please note this Endpoint is not part of the standard API product.)

Figure3

The code below shows you how to extract data from these endpoints

####ReportService
report_info = con.get_pdfReportInfo(productId=x,dtype='dataframe')  #by default dtype='json'
where x be any integer value of existing product ids (for example, 10 for Corporate Data)
#returns all the available report fieldIDs (reportids)
print(report_info)

####ReportService(identifier)(reportid)
report_identifier_reportid = con.get_pdfReportUrl(identifier=x, reportId=y)
#returns the url to given pdf report for specified companies (if available)
print(report_identifier_reportid)

The function supports only 1 identifier and reportID per call.

Universe of Access

The UniverseOfAccess endpoint allows users to determine the list of EntityIds contained in the universe of access (all permissioned securities lists).

Figure4

####UniverseofAccess
universe = con.get_universe_access(dtype='dataframe') #by default dtype='json'
#returns all universe constituents
print(universe)
#### Extra non-Swagger functions
fieldClusterIds = con.get_fieldClusterIds()
#returns all clusterIds
print(fieldClusterIds)

fieldIds = con.get_fieldIds()
#returns all fieldIDs
print(fieldIds)

fieldsInfo = con.get_fieldsInfo()
#returns fields info
print(fieldsInfo)

productIds = con.get_productIds()
#returns product IDs
print(productIds)

packageIds = con.get_packageIds()
#returns package IDs
print(packageIds)

packageInfo = con.get_packageInfo()
#returns package info
print(packageInfo)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sustainalytics-0.2.1.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sustainalytics-0.2.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file sustainalytics-0.2.1.tar.gz.

File metadata

  • Download URL: sustainalytics-0.2.1.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.9.7 Windows/10

File hashes

Hashes for sustainalytics-0.2.1.tar.gz
Algorithm Hash digest
SHA256 15d899f1ac0f52950d6bd87a89481368cfa03149aa38b8bde30c435d527cc4a6
MD5 98f9e09524a320b997a0234d9c946dd5
BLAKE2b-256 89a08a60626ba2be69b5f5a1df2a8791c117aa8c27a69eb21b7706da23a4f255

See more details on using hashes here.

File details

Details for the file sustainalytics-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: sustainalytics-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.9.7 Windows/10

File hashes

Hashes for sustainalytics-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d363f471ff0529a283f29c96b8ea12e1caa50fc0c3d5ed3dab2db61785b8058a
MD5 d87c15433704c8f83ccda9177a23f503
BLAKE2b-256 6c2231b5595ee07aa60e112f35f0de90f437ffb3f9d1b5dbfe23851d03160a4e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page