Text Card
Generates a nice text card
POST /api/cards/text-card
https://api.cookie-api.com/api/cards/text-card
Authentication Learn how to get your API Key and use it in your requests!
URL Parameters | |
---|---|
text | The text that should go on the card |
font_size optional | Size of the font (default: 50) |
background_type | Background type (image, color) |
background_value | Depending on what you chose on background type you either have to input an image url if you chose image or a hex color if you chose color type |
font_family optional | The font that should be used (You can choose from over 1790. You will find them here: https://fonts.google.com , format: simple copy and paste the name of the font, default: Poppins) |
font_color optional | Color of the chosen font (format: HEX, default: black or #000000) |
width optional | Width of the card (format: simply numbers, default: 800) |
height optional | Height of the card (format: simply numbers, default: 600) |
line_spacing optional | Spacing between lines (default: 5) |
You can use over 1790 fonts. You will find them here: https://fonts.google.com
Not sure what font to choose? Try out “Poppins”
curl --location --request POST 'https://api.cookie-api.com/api/cards/text-card?text=I%20love%20cookies&font_size=50&background_type=color&background_value=%23ffffff&font_family=Baumans' \--header 'Authorization: API_Key'
import requests
url = 'https://api.cookie-api.com/api/cards/text-card'headers = { 'Authorization': 'API_Key'}
params = { 'text': 'I love cookies', 'font_size': '50', 'background_type': 'color', 'background_value': '#ffffff', 'font_family': 'Baumans'}
response = requests.post(url, headers=headers, params=params)print(response.json())
const fetch = require('node-fetch');
const url = 'https://api.cookie-api.com/api/cards/text-card';const headers = { 'Authorization': 'API_Key'};
const params = new URLSearchParams({ text: 'I love cookies', font_size: '50', background_type: 'color', background_value: '#ffffff', font_family: 'Baumans'});
fetch(`${url}?${params}`, { method: 'POST', headers}).then(res => res.json()).then(data => console.log(data)).catch(err => console.error(err));
package main
import ( "fmt" "log" "net/http" "net/url" "strings")
func main() { url := "https://api.cookie-api.com/api/cards/text-card" data := url.Values{} data.Set("text", "I love cookies") data.Set("font_size", "50") data.Set("background_type", "color") data.Set("background_value", "#ffffff") data.Set("font_family", "Baumans")
req, err := http.NewRequest("POST", url, strings.NewReader(data.Encode())) if err != nil { log.Fatal(err) }
req.Header.Set("Authorization", "API_Key") req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
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 = new URLSearchParams({ text: 'I love cookies', font_size: '50', background_type: 'color', background_value: '#ffffff', font_family: 'Baumans'}).toString();
const options = { hostname: 'api.cookie-api.com', path: '/api/cards/text-card?' + data, method: 'POST', headers: { 'Authorization': 'API_Key', 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': Buffer.byteLength(data) }};
const req = https.request(options, res => { let responseData = ''; res.on('data', chunk => { responseData += chunk; }); res.on('end', () => { console.log(JSON.parse(responseData)); });});
req.on('error', error => { console.error(error);});
req.write(data);req.end();
require 'net/http'require 'uri'require 'json'
uri = URI.parse('https://api.cookie-api.com/api/cards/text-card')params = { text: 'I love cookies', font_size: '50', background_type: 'color', background_value: '#ffffff', font_family: 'Baumans'}uri.query = URI.encode_www_form(params)
request = Net::HTTP::Post.new(uri)request['Authorization'] = 'API_Key'request['Content-Type'] = 'application/x-www-form-urlencoded'
response = Net::HTTP.start(uri.hostname, uri.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::{Deserialize, Serialize};
#[derive(Serialize)]struct TextCardRequest { text: String, font_size: String, background_type: String, background_value: String, font_family: String,}
fn main() { let url = "https://api.cookie-api.com/api/cards/text-card"; let client = Client::new(); let mut headers = HeaderMap::new(); headers.insert("Authorization", "API_Key".parse().unwrap());
let request_body = TextCardRequest { text: "I love cookies".to_string(), font_size: "50".to_string(), background_type: "color".to_string(), background_value: "#ffffff".to_string(), font_family: "Baumans".to_string(), };
let res = client .post(url) .headers(headers) .json(&request_body) .send() .unwrap();
println!("{}", res.text().unwrap());}
Responses
{ "success": true, "url": "https://cards.cookie-api.com/text-cards/054b1e0f-4625-4556-bd2b-5091806b96e6.png"}