Overview
Introduction
Section titled “Introduction”The card builder is the best way to dynmically generated cards at scale. Whether you use it for your discord bot as welcoming or as booster or even as leaderboard the card builder is the solution. The only real limit of what you can build is your imagination.
Limits
Section titled “Limits”Okay to be fair there are a few limits appart from your imagination:
- All generated cards count towards your storage. They will auto delete after 7 days.
Element limits:
Section titled “Element limits:”Element | Limit |
---|---|
Image | 10 images |
Text | 100 text fields with up to 100 unique fonts |
Discord Profile | 10 Discord profiles |
Roblox Profile | 10 Roblox profiles |
How to build a card
Section titled “How to build a card”To build a card we first have to know what is what. There are 2 so called “Blocks” at the moment which are called “card” and “elements”.
Blocks
Section titled “Blocks”Card Block
Section titled “Card Block”The Card Block is used to provide information about the card itself like background and size. It looks like the following:
{ "card": { // Card parameters here }}
The card parameters define basic things like:
- Card size
- Background Type
- Background value
For the card background you either have the option to use a HEX color as background color or an Image. Here is an example of how the card parameters would look like:
{ "card": { "height": "40", "width": "145", "bg": "https://cdn.cookie-api.com/docs/template.png", // Can be any url that returns an Image "bg_type": "image" }, "elements": [ // All Elements like text, image, roblox profile etc. here ]}
{ "card": { "height": "40", "width": "145", "bg": "#FF0000", "bg_type": "color" }, "elements": [ // All Elements like text, image, roblox profile etc. here ]}
Elements Block
Section titled “Elements Block”The Elements Block is used to specify elements in. You will find the json structure for the elements on the element page.
{ "elements": [ // All Elements like text, image, roblox profile etc. here ]}
Both blocks are needed in every request.
Elements
Section titled “Elements”Currently there are 4 element types available:
How to generate a Card
Section titled “How to generate a Card”To generate a card you have to send a request to the following endpoint:
Generate a Card
Section titled “Generate a Card”POST/api/cards/card-builder/build
https://api.cookie-api.com/api/cards/card-builder/build
{ "card": { // Card parameters here }, "elements": [ // All Elements like text, image, roblox profile etc. here ]}
curl --location 'https://api.cookie-api.com/api/cards/card-builder/build' \--header 'Authorization: API_Key' \--header 'Content-Type: application/json' \--data '// Your card in json format here'
import requests
url = 'https://api.cookie-api.com/api/cards/card-builder/build'headers = { 'Authorization': 'API_Key', 'Content-Type': 'application/json'}data = { # Your card in json format here}
response = requests.post(url, headers=headers, json=data)print(response.json())
const fetch = require('node-fetch');
const url = 'https://api.cookie-api.com/api/cards/card-builder/build';const headers = { 'Authorization': 'API_Key', 'Content-Type': 'application/json'};const data = { // Your card in json format here};
fetch(url, { method: 'POST', headers, body: JSON.stringify(data)}).then(res => res.json()).then(data => console.log(data)).catch(err => console.error('Error:', err));
package main
import ( "bytes" "encoding/json" "fmt" "log" "net/http")
func main() { url := "https://api.cookie-api.com/api/cards/card-builder/build"
data := map[string]interface{}{ // Your card in json format here }
jsonData, err := json.Marshal(data) if err != nil { log.Fatal(err) }
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) if err != nil { log.Fatal(err) }
req.Header.Set("Authorization", "API_Key") req.Header.Set("Content-Type", "application/json")
client := &http.Client{} resp, err := client.Do(req) if err != nil { log.Fatal(err) } defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)}
const https = require('https');
const data = JSON.stringify({ // Your card in json format here});
const options = { hostname: 'api.cookie-api.com', path: '/api/cards/card-builder/build', method: 'POST', headers: { 'Authorization': 'API_Key', 'Content-Type': 'application/json', 'Content-Length': data.length }};
const req = https.request(options, res => { let body = '';
res.on('data', chunk => { body += chunk; });
res.on('end', () => { console.log(JSON.parse(body)); });});
req.on('error', error => { console.error(error);});
req.write(data);req.end();
require 'net/http'require 'json'require 'uri'
url = URI('https://api.cookie-api.com/api/cards/card-builder/build')request = Net::HTTP::Post.new(url)request['Authorization'] = 'API_Key'request['Content-Type'] = 'application/json'request.body = { # Your card in json format here}.to_json
response = Net::HTTP.start(url.hostname, url.port, use_ssl: true) do |http| http.request(request)end
puts JSON.parse(response.body)
use reqwest::blocking::Client;use reqwest::header::HeaderMap;use serde_json::{json, Value};
fn main() { let url = "https://api.cookie-api.com/api/cards/card-builder/build";
let data = json!({ // Your card in json format here });
let client = Client::new(); let mut headers = HeaderMap::new(); headers.insert("Authorization", "API_Key".parse().unwrap()); headers.insert("Content-Type", "application/json".parse().unwrap());
let res = client .post(url) .headers(headers) .json(&data) .send() .unwrap();
let body: Value = res.json().unwrap(); println!("{:?}", body);}
Responses
{ "message": "Card successfully created!", "success": true, "url": "https://cards.cookie-api.com/card-builder/094866000341562/f140a163-4cd5-4b83-a06c-a28ff57ac03d.png"}