DEV Community

Vincent
Vincent

Posted on • Edited on

PixLab API Integration Guide: Quick Setup & Use

PixLab API

The PixLab API offers a robust suite of RESTful endpoints tailored for modern developers. Whether you're building an eKYC flow, a creative image editing tool, or a document automation pipeline, PixLab has the tools you need. Integrate the PixLab API for image analysis, ID scanning, LLM Parse tool, Background removal, Dynamic PDF Generation, OpenAI Chat Compatible API & more via simple REST HTTP requests. No SDK Needed!


🚀 Step 1: Get Your API Key

Every request to PixLab starts with an API key.

  1. Visit the PixLab Console and sign up.
  2. Access your API key from the console and keep it secure.
  3. Visit the API Portal to decide which API to use in production for your specific tasks. All PixLab endpoints are SDK-free, RESTful, and can be called from your favorite programming environment as long as it supports HTTPS.

🪪 Use Case #1: Automated ID Scanning via docscan

PixLab’s docscan endpoint extracts structured data from identity documents like passports and licenses.

  • Supports: 11,000+ ID types from 197+ countries
  • Endpoint Documentation: /DOCSCAN
  • Use Cases: KYC, age verification, onboarding workflows

Upload an image of a government-issued ID, and get clean, structured JSON data back—no manual parsing required.

import requests
import json

# Scan over 11K ID Documents from over 197 countries using the PixLab DOCSCAN API Endpoint
# documented at: https://pixlab.io/id-scan-api/docscan
#
# In this example, given a Passport document, extract the passport holder face and convert/parse all Machine Readable Zone
# to textual content ready to be consumed by your application.
#
# PixLab recommend that you connect your AWS S3 bucket via the dashboard at https://console.pixlab.io
# so that any extracted face or MRZ crop is automatically stored on your S3 bucket rather than the PixLab one.
# This feature should give you full control over your analyzed media files.
#
# Refer to the official documentation at: https://ekyc.pixlab.io/docscan for the API reference guide and more code samples.

req = requests.get(
    'https://api.pixlab.io/docscan', 
    params={
        'img':'https://i.stack.imgur.com/oJY2K.png', # Passport Input Image or switch to POST if you want to upload your image direclty
        'type':'passport', # Type of document we are a going to scan
        'key':'PIXLAB_API_KEY' # Get your PixLab API Key from https://console.pixlab.io
    }
)
reply = req.json()
if reply['status'] != 200:
    print (reply['error'])
else:
    print(f"User Cropped Face: {reply['face_url']}")
    # Display all extracted fields from the ID document
    print(f"Document Number: {reply['fields']['documentNumber']}")
    print(f"Issuing Country: {reply['fields']['issuingCountry']}")
    print(f"Full Name: {reply['fields']['fullName']}")
    print(f"Date Of Birth: {reply['fields']['dateOfBirth']}")
    # Fields that varies from different ID types
    if 'checkDigit' in reply['fields']:
        print(f"\tCheck Digit: {reply['fields']['checkDigit']}")
    if 'nationality' in reply['fields']:
        print(f"\tNationality: {reply['fields']['nationality']}")
    if 'sex' in reply['fields']:
        print(f"\tSex: {reply['fields']['sex']}")
    if 'dateOfExpiry' in reply['fields']:
        print(f"\tDate Of Expiry: {reply['fields']['dateOfExpiry']}")
    if 'personalNumber' in reply['fields']:
        print(f"\tPersonal Number: {reply['fields']['personalNumber']}")
    if 'finalcheckDigit' in reply['fields']:
        print(f"\tFinal Check Digit: {reply['fields']['finalcheckDigit']}")
Enter fullscreen mode Exit fullscreen mode

🧠 Use Case #2: Document AI via the Vision Platform

PixLab’s Vision VLM Platform combines NLP and computer vision to queries images and video frames, parse unstructured documents like invoices, contracts, and receipts.

  • Endpoint: /QUERY VLM API Endpoint
  • Use Cases: Receive natural language responses to image-related queries

  • Endpoint: /BG-REMOVE Image Processing API Endpoint

  • Use Cases: Background & Object Removal

  • Endpoint: /LLM-TOOL LLM Tool Calling API Endpoint

  • Use Cases: LLM Tools & MCP Services to be called by your LLM workflow

  • Endpoint: /IMG-EMBED LLM Embedding API Endpoint

  • Use Cases: Generate an image embedding vector for image indexing & similarity search

  • Endpoint: /PDF-GEN Dynamic PDF Generation API Endpoint

  • Use Cases: Generate PDF programmatically from Markdown or HTML input using SDK-Free REST API.

  • Endpoint: /PDF-TO-IMG PDF Convertion API Endpoint

  • Use Cases: Convert PDF to images using SDK-Free REST API.

  • Endpoint: /DOCSCAN ID Scanning API Endpoint

  • Use Cases: Scan and extract structured JSON data from over 11,000 ID documents

  • Endpoint: /NSFW Detection API Endpoint

  • Use Cases: Content Moderation API

Define your data schema, and the AI handles layout variations across documents. Refer to the list of [API Endpoints](https://pixlab.io/api-endpoints] for the complete documentation, and official reference guide of all the API endpoints exposed here.



import requests
import json

# Get natural language responses to image-related queries

# Target Image: Change to any link or switch to POST if you want to upload your image directly, refer to the REST API code samples for more info.
img = 'https://pixlab.io/assets/images/nature31.jpg' 

key = 'PIXLAB_API_KEY' # Get your API key from https://console.pixlab.io/

req = requests.get('https://api.pixlab.io/query',params={
  'img':img,
  'key':key,
  'lang':'english',
  'query':'What does this image depict? Can you guess the location where it was taken?'
})
reply = req.json()
if reply['status'] != 200:
    print (reply['error'])
else:
  response = reply['response']
  print(f"Query Response: {response}")

Enter fullscreen mode Exit fullscreen mode

🖼️ Use Case #3: Instant Background Removal

Perfect for e-commerce, user avatars, or profile tools, bg-remove removes image backgrounds in seconds.

  • Endpoint: /BG-REMOVE
  • Use Cases: Transparent product photos, creative marketing, profile customization

Just send an image URL or upload a BASE64 Encoded image and get back a transparent PNG.

# Remove background programmatically using the PixLab /bgremove
# API endpoint - https://pixlab.io/endpoints/background-remove-api

import requests

res = requests.post("https://api.pixlab.io/bgremove", json={
  "url": "https://source.unsplash.com/random/800x600",
  "key": "YOUR_API_KEY"
})

if res.headers.get("Content-Type", "").startswith("image/"):
    with open("no_bg.png", "wb") as f:
        f.write(res.content)
Enter fullscreen mode Exit fullscreen mode

🔧 Other Powerful Features

PixLab provides over 150 API endpoints for nearly every media manipulation or analysis task:

Explore all tools at pixlab.io/api-endpoints


✅ Start Building Today

PixLab is developer-first: clean REST APIs, comprehensive docs, and flexible usage-based pricing.

Whether you're building for e-commerce, identity verification, or creative media tooling, PixLab is the full-stack API solution to accelerate your development.

Top comments (0)