Skip to main content

Python 3 bindings for Graylog's REST API

Project description


(Pronounced: gray-P-I)

Python3 bindings for Graylog's REST API


First, make sure you have at least Python 3.7 installed.


git clone
cd grapi
pipenv install

Library Usage

pip3 install grapi

Example Usage

To use, you must first create an access token following the instructions at: Graylog REST API Documentation API does not support username/password logins as it makes it easier to accidentally expose user credentials.

Import after installation with pip: from grapi.grapi import Grapi

Import access token string: token = "<your_access_token_string>"

Set URL to desired API path: url = "https://<your Graylog URL>/api/search/universal/absolute"

All currently implemented URL endpoints can be found in: grapi/

The list of all possible endpoints that may be implemented in the future is found by adding /api/api-browser to the URL of your Graylog server.

Setup the Grapi object with url and token: my_api = Grapi(url, token)

Build a dictionary of parameters mapped to string values for every parameter of your request:

my_params = {
  "query": "<your query string (lucene syntax)>", # Required
  "fields": "<fields you wish returned>", # Required
  "from": "<YYYY-MM-DD HH-MM-SS>", # Required
  "to": "<YYYY-MM-DD HH-MM-SS>", # Required
  "limit": 10 # Optional: Default limit is 150 in Graylog

Now, simply call the send method of my_api with the type of request method (get, post, put, delete): response = my_api.send("get", **my_params)

That's it for a simple search in Python 3 using Graylog's REST API! Now you can manipulate the data however you wish directly in Python. To see the output of your search you can just print it as with anything else in Python:


This is a work in progress, so if the method or endpoint you need isn't yet implemented, add it yourself and send a pull request, post to issues, or simply check back later and it should be added.

Project details

Download files

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

Files for grapi, version 0.1.4
Filename, size File type Python version Upload date Hashes
Filename, size grapi-0.1.4-py3-none-any.whl (6.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size grapi-0.1.4.tar.gz (4.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page