{% extends "master.html" %} {% block title %} API documentation {% endblock %} {% block content %}

Tagger API

The API can be used to add a tag, a rating or retrieve the tags, rating associated with a package.

Get package information

This happens at the url {{ url_for('api.pkg', pkgname='pkgname') }} It needs one argument and will just return a json containing the information about this package.

Example output:

curl http://.../api/v1/guake/ { "rating": 83.333333333333329, "icon": "/packages/images/icons/__no_xapian_available__.png", "summary": "", "name": "guake", "tags": [ { "total": 1, "dislike": 0, "tag": "terminal", "votes": 1, "like": 1 }, { "total": 0, "dislike": 1, "tag": "gnome", "votes": 2, "like": 1 } ] }

Retrieve tags of a package

This happens at the url {{ url_for('api.pkg_tag', pkgname='pkgname') }} It needs one argument relies on GET requests and will just return a json containing the tags associated to this package.

Example output:

curl http://.../api/v1/guake/tag/ { "name": "guake", "tags": [ { "total": 1, "dislike": 0, "tag": "terminal", "votes": 1, "like": 1 }, { "total": 1, "dislike": 0, "tag": "gnome", "votes": 1, "like": 1 } ] }

Retrieve rating of a package

This happens at the url {{ url_for('api.pkg_rating', pkgname='pkgname') }} It needs one argument, relies on GET requests and will just return a json containing the rating associated to this package.

Example output:

curl http://.../api/v1/guake/rating/ { "rating": 75.0, "name": "guake" }

Set tags

This happens at the url {{ url_for('api.tag_pkg', pkgname='pkgname') }} It needs two arguments, relies on PUT requests and will just return a json with information on how the request performed.

Example output:

curl -X PUT --data "tag=terminal&pkgnme=guake" http://.../api/v1/tag/guake/ { "output": "notok", "error_detail": [ "Pkgname: This field is required." ], "error": "Invalid input submitted" } curl -X PUT --data "tag=terminal&pkgname=guake" http://.../api/v1/tag/guake/ { "output": "ok", "messages": [ "Tag \"terminal\" added to the package \"guake\"" ] }

Retrieve packages with tag

This happens at the url {{ url_for('api.tag_pkg', pkgname='pkgname') }} It needs one arguments, relies on GET requests and will just return a json with information on how the request performed.

Example output:

curl http://.../api/v1/tag/terminal/ { "tag": "terminal", "packages": [ { "votes": 2, "like": 2, "package": "guake", "tag": "terminal", "dislike": 0, "total": 2 } ] }

Set rating

This happens at the url {{ url_for('api.rating_pkg', pkgname='pkgname') }} It needs two arguments, relies on PUT requests and will just return a json containing the rating associated to this package.

Example output:

curl -X PUT --data "pkgname=guake&ratin=100" http://.../api/v1/rating/guake/ { "output": "notok", "error_detail": [ "rating: This field is required." ], "error": "Invalid input submitted" } curl -X PUT --data "pkgname=guake&rating=100" http://.../api/v1/rating/guake/ { "output": "ok", "messages": [ "Rating \"100\" added to the package \"guake\"" ] }

Retrieve packages with a specific rating

This happens at the url {{ url_for('api.tag_pkg', pkgname='pkgname') }} It needs one arguments, relies on GET requests and will just return a json with information on how the request performed.

Example output:

curl http://.../api/v1/rating/75/ { "rating": 75.0, "packages": [ "guake" ] } curl http://.../api/v1/rating/76/ { "output": "notok", "error": "No packages found with rating \"76.0\"" }

Vote on the tag of a package

This happens at the url {{ url_for('api.vote_tag_pkg', pkgname='pkgname') }} It needs three arguments, relies on PUT requests and will just return a json containing the rating associated to this package.

Example output:

curl -X PUT --data "pkgname=guake&tag=terminal&vote=1" http://.../api/v1/vote/guake/ { "output": "ok", "messages": [ "Vote added to the tag \"terminal\" of the package \"guake\"" ] } curl http://.../api/v1/tag/guake/ { "name": "guake", "tags": [ { "total": 2, "dislike": 0, "tag": "terminal", "votes": 2, "like": 2 }, ] } curl -X PUT --data "pkgname=guake&tag=terminal&vote=-1" http://.../api/v1/vote/guake/ { "output": "ok", "messages": [ "Vote changed to the tag \"terminal\" of the package \"guake\"" ] } curl http://.../api/v1/tag/guake/ { "name": "guake", "tags": [ { "total": 0, "dislike": 1, "tag": "terminal", "votes": 2, "like": 1 } ] }

Retrieve the leaderboard

This happens at the url {{ url_for('api.leaderboard') }} It does not take any argument, relies on GET requests and will return a json with the top 10 contributors to tagger.

Example output:

curl http://.../api/v1/leaderboard/ { "1": { "score": 0, "gravatar": "<img src='http://www.gravatar.com/avatar/a04d77b61372a61cc4f064f7e5bbb2f4?s=32&d=mm'></img>", "name": "lmacken" }, "2": { "score": 0, "gravatar": "<img src='http://www.gravatar.com/avatar/71bcc747a3911e12789b00ebabd31889?s=32&d=mm'></img>", "name": "nonamedotc" }, "3": { "score": 0, "gravatar": "<img src='http://www.gravatar.com/avatar/2bd6d5b82bf626fbc5e38ea942f34ffb?s=32&d=mm'></img>", "name": "gcampax" }, "4": { "score": 0, "gravatar": "<img src='http://www.gravatar.com/avatar/fe0be0dc71bd3c89fe3a4ffde5a5cb01?s=32&d=mm'></img>", "name": "keramidas" } }

Retrieve someone's score

This happens at the url {{ url_for('api.score', username='username') }} It takes one argument, relies on GET requests and will return a json with the .

Example output:

curl http://.../api/v1/score/pingou/ { "score": 0, "gravatar": "<img src='http://www.gravatar.com/avatar/072b4416fbfad867a44bc7a5be5eddb9?s=32&d=mm'></img>", "name": "pingou" }

Retrieve database statistics

This happens at the url {{ url_for('api.statistics') }} It does not take any argument, relies on GET requests and will return a json with some basic statistics about the tags in the database.

Example output:

curl http://.../api/v1/statistics/ { "summary": { "tags_per_package": 0.64386180527106374, "with_tags": 3466, "tags_per_package_no_zeroes": 2.7207155222158108, "no_tags": 11180, "total_packages": 14646, "total_unique_tags": 2865 } }

Bulk exporting data

There are a handful of ways to bulk export tagger data.

Export all package tags as tab-separated values:

curl http://.../api/v1/tag/dump/

Export all package ratings as tab-separated values:

curl http://.../api/v1/rating/dump/

Backwards compatibility exports

A few URLs exist for exporting tagger data to other older Fedora Infrastructure webapps

Export all tags as JSON for the fedora-packages webapp indexer:

curl http://.../api/v1/tag/export/

Export all tags as JSON for the bodhi masher:

curl http://.../api/v1/tag/sqlitebuildtags/
{% endblock %}