Toolset · BugSwarm REST API
Installation
Requires Python 3.
$ pip3 install bugswarm-common
Filtering and Retrieving Artifact Metadata
There are a few functions that are of interest in regards to filtering and retrieving metadata of artifacts.
find_artifact(image_tag)
: Returns the metadata about an artifact.list_artifacts()
: Returns a list of artifacts' metadata that are Java or Python and have at least one reproduce success.filter_artifacts(filter_str)
: Returns a list of artifacts' metadata based on a custom filter. The filter should use MongoDB query syntax.get_build_log(job_id)
: Returns the original build log of a job.
Usage
(Optional) Request a token.
You can use the BugSwarm API without an API token, but unauthenticated requests are limited to 20 per minute.
Authenticated requests are not rate limited.
Note that since DatabaseAPI
methods page through results automatically, one method call can make multiple requests.
Import the DatabaseAPI and create an instance of it.
>>> from bugswarm.common.rest_api.database_api import DatabaseAPI
>>> bugswarmapi = DatabaseAPI(token='AN_OPTIONAL_TOKEN')
>>> unauthenticated_api = DatabaseAPI() # Rate limited
Using the API to filter artifacts such that artifacts that are returned are: Java and are flaky.
>>> api_filter = '{"reproduce_successes":{"$gt":0, "$lt":5}, "lang":"Java"}'
>>> bugswarmapi.filter_artifacts(api_filter)
Using the API to retrieve metadata for one artifact.
>>> bugswarmapi.find_artifact('Abjad-abjad-289716771')
Using the API to retrieve the original log of a job.
>>> bugswarmapi.get_build_log('289716771')
Using the API to retrieve metadata for all artifacts that are Java or Python and have at least one reproduce success. This includes deprecated artifacts.
>>> bugswarmapi.list_artifacts()
Source
The BugSwarm REST API is located here.