> For the complete documentation index, see [llms.txt](https://allqueue.gitbook.io/allq/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://allqueue.gitbook.io/allq/usage.md).

# Rest API Usage

The only way to communicate with the AllQServer is **through** the AllQClient.

By default, the AllQClient offers a RESTful API for communicating with the AllQServer. This HTTP API is configurable via environment variables.

**HTTP\_SERVER\_PORT** = 8090 *(default)*

You application will call into this local http server with JSON and standard REST API calls.

## How do I use AllQ now?

The simplest way is to use the REST API provided by the AllQClient.

The AllQClient is running a simple http server on localhost. This **REST API** is defined here:

{% embed url="<https://app.swaggerhub.com/apis-docs/Blitline/all-q/1.0>" %}

{% hint style="success" %}

{% endhint %}

![AllQueue Rest API](/files/-M0Ed41NBd1BX6bajvxc)

{% hint style="success" %}
You can download a REST API client from the website above. Each client will have it's own syntax around making the REST API call, but they all follow the same REST pattern. You should be able to derive your necessary calls from the libraries you download
{% endhint %}

Alternately, you can use a REST API library from your language of choice, and simply use the defined API above. In the example below, we will use the Ruby AllQ gem.

## Example

```
gem install allq_rest
```

Here is a simple ruby example that will put and get items from your server. This gem is just a thin wrapper around the REST API.

{% hint style="info" %}
You must run this ON a machine that has the AllQClient installed. The REST API client assumes localhost:8090.
{% endhint %}

{% tabs %}
{% tab title="Ruby" %}

```ruby
require 'allq_rest'
require 'base64'

base_client = Allq::ApiClient.new(Allq::Configuration.new)
@worker_client = Allq::ActionsApi.new(base_client)
@admin_client = Allq::AdminApi.new(base_client)

def done(job)
 @worker_client.job_delete(job.id)
end

def stats
  @admin_client.stats_get
end

def put_job(tube_name, data)
  job = build_new_job(data, { tube_name: tube_name})
  @worker_client.job_post(job)
end

def get_job(tube_name)
  @worker_client.job_get(tube_name)
end

def build_new_job(data, options)
  ttl = options[:ttl] || 600
  tube_name = options[:tube_name] || 'default'
  delay = options[:delay] || 0
  parent_id = options[:parent_id]

  new_job = Allq::NewJob.new(tube: tube_name,
                         body: data,
                         ttl: ttl,
                         delay: delay,
                         priority: 5,
                         parent_id: parent_id)
  new_job
end

# Put job on queue
put_job("my_tube_name", "Some data I want to push to queue")
# Get job off queue
job = get_job("my_tube_name")
# Output data (allq_client gem base64 encodes body)
puts Base64.decode64(job.body)
# Mark job as done
done(job)

# Example of stats from server
puts "Stats:", stats
```

{% endtab %}
{% endtabs %}

Save this file as test.rb and simply run it via:

```ruby
ruby test.rb
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://allqueue.gitbook.io/allq/usage.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
