Wikirate platform helps users to find/research answers on specific questions/metrics about companies. Thus, each answer is described by the question/metric, company, value, year and source.
This example assumes you have configured your Wikirate REST client
. Instructions on how to configure a client can be
found in examples/Configurations.md
The get_answers
method take as an input the metric_name
, metric_designer
and a Hash
where the user can define
the parameters of their request. More specifically, we could divide our params in two different types of parameters, the
endpoint parameters and the filter parameters. The endpoint parameters help us to iterate through our query's results
and the filter parameters allow us to restrict our results based on specific given input.
- limit: default value 20, the maximum number of entries to return. If the value exceeds the maximum, then the maximum value will be used.
- offset: default value 0, the (zero-based) offset of the first item in the collection to return
filter params:
-
year: returns all metric answers of the defined year
-
verification: returns all metric answers of the defined verification status. Allowed parameter values:
- 'flagged'
- 'community_added': Unverified - added by community
- 'steward_added': Unverified - added by steward
- 'community_verified': Verified by community
- 'steward_verified': Verified by steward
-
value: returns all metric answers with the defined value
-
value_from: returns all metric answers where their value is greater or equal to the defined value
-
value_to: returns all metric answers where their value is less or equal to the defined value
-
status: returns all metric answers of the defined status. Allowed parameter values:
- 'exists': Researched - All
- 'known': Researched with a known value
- 'unknown': Research with an unknown value
- 'none': Not researched
- 'all': Researched and Not researched
-
source: returns all metric answers that cite the defined source
-
updated: returns all metric answers that updated on the defined period. Allowed parameter values:
- 'today'
- 'week': current week
- 'month': current month
-
dataset: returns all metric answers that belong to the define dataset. All available wikirate datasets can be found here.
-
company_id: returns all metric answers of the defined company given its identifier.
-
company_name: returns all metric answers of companies that contain in their name the given string
-
company_category: returns all metric answers of companies that belong to a given company category. Available company categories. Allowed parameter values:
- 'F': Financial
- 'H': Health And Education
- 'I': Infrastructure
- 'M': Manufacturing
- 'R': Raw Material Producer
- 'S': Science And Technology
- 'W': Wholesale And Retail
- 'O': Other
-
company_group: returns all metric answers of companies that belong to a given company group. All wikirate company groups can be found here.
-
country: returns metric answers of companies with headquarters on the given input country. All available wikirate country options can be found here.
In the example below, we are looking for community verified answers of companies with Direct greenhouse gas (GHG) emissions (Scope 1) greater or equal to 1M CO2 tonnes in 2021.
answers = client.get_answers('Direct greenhouse gas (GHG) emissions (Scope 1), GRI 305-1-a (formerly G4-EN15-a)',
'Global Reporting Initiative',
{ 'year' => 2021,
'value_from' => 1000000,
'verification' => 'community_verified' })
puts answers
In the example below, we are looking for the latest available data on Direct greenhouse gas (GHG) emissions (Scope 1) of companies located in the United Kingdom
answers = client.get_answers('Direct greenhouse gas (GHG) emissions (Scope 1), GRI 305-1-a (formerly G4-EN15-a)',
'Global Reporting Initiative',
{ 'year' => 'latest',
'country' => 'United Kingdom' })
puts answers
The get_answers_by_metric_id
functions similarly with the get_answers
method but instead of metric_name
and metric_designer
gets as an input the metric_id
.
Thus, the examples equivalent examples of the previous section using the metric_id will be formulated as follows:
In the example below, we are looking for community verified answers of companies with Direct greenhouse gas (GHG) emissions (Scope 1) greater or equal to 1M CO2 tonnes in 2021.
answers = client.get_answers(826615, { 'year' => 2021,
'value_from' => 1000000,
'verification' => 'community_verified' })
puts answers
In the example below, we are looking for the latest available data on Direct greenhouse gas (GHG) emissions (Scope 1) of companies located in the United Kingdom
answers = client.get_answers(826615, { 'year' => 'latest',
'country' => 'United Kingdom' })
puts answers