Public API
Programmatically interact with Open Measures' data using the Public API
Getting Started
Open Measures values transparency and is proud to offer a free platform in order to help contextualize on- and offline harm. One powerful piece of the platform is the Public API.
Open Source API: https://gitlab.com/openmeasures/backends/openmeasures-api
There's a link to the API on the Open Source section of the Open Measures website along with more details on the rate-and date-limiting of the Public API:

Endpoints
The API has access to the raw JSON behind all front-end tools and can be useful for developers and analysts who want to dive deeper into the data or make more fine-grained queries. The API has three endpoints and has an optional boolean logic query for the Content
endpoint.
All API endpoints are hosted at:
Boolean and Advanced
Each endpoint in the API has the ability to make more advanced queries. This works by leveraging an Elasticsearch query_string_query
(Elasticsearch docs).
querytype
This parameter allows the user to run one of the following conditions. It is an enum
and expects a string
parameter:
content
This will run an API request to find documents where the input value for term
appears in the content field.
qanon Will return docs where "qanon" appears in the content field.
boolean_content
This will run an API request to find documents where the boolean condition specified in the term
parameter appears in the content field.
qanon AND wwg1wga Will return docs where "qanon" and "wwg1wga" appear in the content field
query_string
This will run an API request using the Elasticsearch query_string_query
syntax. It will search across all fields unless specified in the query.
(channelusername:rtnews) AND (message:russia)
Returns docs where the channelusername
field is set to rtnews
and where the message
field contains russia
esquery
This parameter will eventually be deprecated. We recommend using querytype
to avoid disruption.
The default for this parameter is False
which means that the API will only search a single term through the document's content field.
NOTE: Setting esquery to True will yield the same results as setting querytype
to query_string
.
A full list of content fields can be found in our open-source code here:
When this is set to True
the API will interpret the value of the term
parameter as a raw Elasticsearch query.
Example:
import requests
PARAMS = {
"site": "win",
"term": "qanon OR wwg1wga OR #qanon OR #wwg1wga",
"esquery": True
}
API_URL = "https://api.openmeasures.io/content"
# This will return results where the terms appear
# in any of the fields in the documents
response = requests.get(API_URL, params=PARAMS)
hits = response.json()["hits"]['hits']
Examples
Notebook
Here is a link to a Quick Start Code Guide in Colab or Jupyter notebook format for making requests to our API.

Command Line Tool
We also have a CLI, originally built by a community member, that we forked. Separately, there is the following GitHub repo (https://github.com/cabalcx/smatter/tree/main), also built by community members, that implements a similar wrapper.

Example Content Endpoint Query
First, click the Content endpoint and then click “Try it out”.

Choose Telegram as the Site, and then click Execute. It will give you a regular URL link that will have the raw JSON content of your query. The interface will look like this:
If you Curl or go to the URL you will get a raw JSON that will look like the following (certain browsers like Firefox will automatically “prettify” the JSON to make it easier to read):

Example of the same request using curl from the command line and jq to pretty print:

Everything is nested in “hits
” and “_source
” for all of our data.
API Workflow Example
The Open Measures API is able to be fine-tuned to your exact needs. To show this, we will spell out the steps necessary to pull up to 10k of Guo Wengui’s posts on Gettr as a reference to our post outlining some of the happenings on the alt-tech platform. This post builds upon the information shown in our original API guide. The key element of this advanced usage is using the term query with Elasticsearch query string syntax while setting the es_query field to True.
After heading over to our interactive API docs click the content button:

Content button in Open Measures' interactive API docs tool
Click “Try it out.”
Next to “term” write any interesting word for now.
On “site” select “Gettr.”
Leave all the other settings default for now and click “Execute.”
This will generate a “Request URL” if you copy that link into a new browser window you will be offered a JSON of the data you requested.
Now that you have some examples of the format of the data you want to explore, dig through it to find the field (or “key”) you want to search under. In our case, we are interested in a field under “uinf” called “username” because we are doing author search. The best way to find the intended field is to look through the JSON results from this /content query.

Prettified JSON blob highlighting the username field.
User Search
Now that we know what field corresponds to the username in the JSON, we are ready to search for the posts written by a specific user on Gettr.
We can now construct our input to the term field in the API. We combine uinf.username with the specific username, in this case “miles”, we are interested in searching using the following syntax: “uinf.username:miles”.
NOTE: For those wishing to learn more about the query language behind these requests check out this documentation.
Then we can configure the remaining Open Measures API arguments:
We can raise the “limit” (which is the limit of posts returned) to the maximum of 10,000
We can then extend the “since” field
And finally, we set the “esquery” boolean item to “true”. This just means that in the term box, instead of accepting a regular search phrase it’s using “Boolean logic” to search through specific fields.
Review the following screenshot to make sure your fields look the same:

When you have the JSON opened in a new tab (here’s a direct link to the query we've just demonstrated), you may have to click to expand some of the fields. Most of the content you're interested in here will be under: hits > a number > _source. Once there, you will see the contents of the message as the field named “txt” as well as other information.

Content Fields
When querytype
is set to content
or boolean_content
the API will search through the default content field for each site. A list of the content field per site can be found in the open-source API code base which is embedded below.
Further Research
Once you’ve got the hang of searches for all of an actor's posts you can experiment with other advanced queries over any of the other fields in any of the other sources such as language, location, URLs, etc.
Follow along with our independent research work and reach out if you're interested in contributing!
Last updated