The $http functions let your bot send and receive data over the internet. The services it talks to are called APIs, think of them as websites designed for bots: instead of a page with text and images, they return raw data (usually JSON) that your bot can use directly.
There are different types of requests for different jobs:
- GET: read data from an API (
$httpGet[URL]) - POST: send new data to an API (
$httpPost[URL;(Body)]) - PUT: replace existing data on an API (
$httpPut[URL;(Body)]) - PATCH: update part of existing data on an API (
$httpPatch[URL;(Body)]) - DELETE: remove data from an API (
$httpDelete[URL;(Body)])
Each type has its own function, and they all work the same way: you call the function, BDFD stores the response, then you use $httpResult to return it. With these functions you can build:
- AI chatbots: talk to an AI API
- Economy systems: save and load user balances from a database
- Weather commands: get live weather data
- Quote or joke commands: pull content from public APIs
- Custom databases: connect your bot to your own backend
Functions are grouped into three categories. Each category has its own folder, and each function has its own page.
Use: making calls to APIs
Functions:
$httpGet,$httpPost,$httpPut,$httpPatch,$httpDelete
Use: extra information attached to your requests and responses, like metadata your bot sends or receives alongside the actual data.
Functions:
$httpAddHeader,$httpRemoveHeader,$httpGetHeader
Use: returns what comes back and check the API's status.
Functions:
$httpResult,$httpStatus.
- What the function does
- The exact syntax (how to write it)
- What happens when you call it
- One or two simple examples you can try
- Common uses for the function
- Related functions to check next
Pick the function you need from the table below and click it.
| Function | What it does |
|---|---|
| $httpGet | Requests data from an API |
| $httpPost | Sends data to an API |
| $httpPut | Updates an existing resource on an API |
| $httpPatch | Partially updates an existing resource on an API |
| $httpDelete | Deletes a resource from an API |
| $httpAddHeader | Adds a custom header to your HTTP request |
| $httpRemoveHeader | Removes a header from your HTTP request |
| $httpStatus | Gets the HTTP status code of the response |
| $httpResult | Gets the data returned by your HTTP request |
| $httpGetHeader | Gets a specific header from the response |
If you are completely new to HTTP functions, start with these two in order:
- $httpGet: the simplest function. It just make the request.
- $httpResult: used right after
$httpGetto return the data.
Once you understand those two, the rest will be much easier to follow.
All syntax shown in this guide is checked against BDFD's official wiki and official function list.