KARATHEN API MODEL
API Tech Solutions provides scalable and secure API development and integration services to enhance business efficiency.
General API Field Guide
A practical, architect-level field guide to modern integrations—covering auth models, common workflows, sample requests, and production gotchas.
UPS API
UPS provides REST endpoints for rating, shipping/labels, pickups, address validation, and tracking. Typical environments include a sandbox and production, with strict validation on addresses, service levels, and packaging.
Auth & Environment
- Auth: OAuth 2.0 (client credentials) yielding short-lived access tokens.
- Environments: Sandbox (test) and Production; keep shipper numbers & account IDs separate.
- Scope: Enable only the products you need (Rate, Ship, Track) to avoid permission errors.
Core Capabilities
- Rates by service (e.g., Ground, 2nd Day Air), including negotiated rates.
- Shipment creation with label formats (PDF, ZPL/EPL) and return labels.
- Tracking lookups (single or batch) with status milestones.
- Address validation & classification (residential vs. commercial).
Typical Flow
- Validate/normalize address.
- Get rates (dim weight, declared value, special services).
- Create the shipment → receive label + tracking number.
- (Optional) Schedule a pickup; store tracking events.
Common Gotchas
- Dimensional weight rules affect cost—always send accurate dimensions.
- International shipments require customs docs (HS codes, reason for export).
- Label format must match your printer (ZPL for thermal, PDF for laser).
- Residential/commercial misclassification can change rates/surcharges.
Sample: Get Access Token & Create Shipment
# 1) Token (Client Credentials)
curl -X POST https://{ups-auth-host}/security/v1/oauth/token \
-u "<client_id>:<client_secret>" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials"
# 2) Create Shipment (simplified)
curl -X POST https://{ups-host}/api/shipments/v1/ship \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{
"shipper": {"name":"Karathen API","number":"<shipperNumber>"},
"shipTo": {"name":"Jane Doe","address":{"line1":"500 Main St","city":"Tampa","state":"FL","postalCode":"33602","country":"US"}},
"packages": [{"weight":{"unit":"LB","value":3.2},"dimensions":{"unit":"IN","length":12,"width":8,"height":4}}],
"serviceCode":"03", // Example: Ground
"label":{"format":"PDF"}
}'
FedEx API
Modern FedEx APIs expose rating, shipping/labels, tracking, and pickups via OAuth 2.0 with distinct sandbox and production endpoints. Plans and permissions are tied to your FedEx account.
Auth & Setup
- Auth: OAuth 2.0 client credentials → access token.
- Account: Ensure shipping services are enabled on the account you’ll bill.
- Labels: PDF & ZPL/EPL; support for returns and paperless trade where applicable.
Key Endpoints
- Rates: quote services, add options (signature, Saturday delivery).
- Ship: create, cancel, and return shipments.
- Track: detailed scan events, proof-of-delivery where permitted.
- Pickup: schedule/cancel pickups; cutoff/business days logic.
Sample: Token & Rate Quote
# 1) Access Token
curl -X POST https://{fedex-auth-host}/oauth/token \
-u "<client_id>:<client_secret>" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials"
# 2) Get Rates (simplified)
curl -X POST https://{fedex-host}/rate/v1/rates/quotes \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{
"accountNumber":{"value":"<acct>"},
"requestedShipment":{
"shipper":{"address":{"postalCode":"33602","countryCode":"US"}},
"recipient":{"address":{"postalCode":"90001","countryCode":"US","residential":true}},
"pickupType":"DROPOFF_AT_FEDEX_LOCATION",
"requestedPackageLineItems":[{"weight":{"units":"LB","value":3.2}}],
"serviceType":"FEDEX_GROUND"
}
}'
USPS API
USPS “Web Tools” have long provided XML-based endpoints for domestic/international rate quotes, tracking, and address verification. Full label creation usually goes through approved programs (e.g., eVS) or PC-Postage partners rather than the public Web Tools.
Auth & Access
- Credential: Web Tools
USERID
(and sometimes password) assigned per account. - Usage: Legacy XML over HTTP; some newer endpoints offer REST. IP whitelisting may apply.
What You Can Do
- Rates: USPS retail/commercial pricing for supported services.
- Tracking: basic scan events by tracking number.
- Address checks: ZIP lookup, City/State, and standardization.
- Labels: typically via eVS/PC-Postage rather than public XML API.
Sample: Domestic Rate (legacy XML)
# GET with XML payload (legacy pattern; encode the XML)
https://secure.shippingapis.com/ShippingAPI.dll?API=RateV4&XML=<RateV4Request USERID="<USERID>">
<Package ID="1">
<Service>PRIORITY</Service>
<ZipOrigination>33602</ZipOrigination>
<ZipDestination>90001</ZipDestination>
<Pounds>3</Pounds>
<Ounces>3.2</Ounces>
<Container>VARIABLE</Container>
<Size>REGULAR</Size>
<Machinable>true</Machinable>
</Package>
</RateV4Request>
Amazon Seller API (SP-API)
Amazon’s Selling Partner API (SP-API) powers listings, orders, reports, feeds, and more. Auth combines Login With Amazon (LWA) and AWS Signature v4. Permissions/scopes are strict, and throttling is per-operation.
Auth Layers
- LWA: Exchange refresh token → access token for the selling partner’s account.
- AWS SigV4: Sign each HTTP request (region & service specific).
- RDT: Restricted Data Tokens for PII fields (e.g., buyer info).
Key Domains
- Orders: list/get orders & line items; acknowledge, ship, confirm.
- Catalog & Listings: list catalogs, create/update offers & prices.
- Feeds/Uploads: bulk operations (inventory, pricing, listings).
- Reports: schedule & download; flat files and JSON.
Sample: Create a Feed (2-step upload)
# Pseudocode-ish: 1) create a "document" to upload to
POST /feeds/2021-06-30/documents
{ "contentType": "text/tab-separated-values; charset=UTF-8" }
# → returns { url, encryptionDetails, documentId }
# 2) PUT your file to the pre-signed S3 URL with encryption details
PUT <url>
<file bytes>
# 3) Create the feed referencing the documentId
POST /feeds/2021-06-30/feeds
{ "feedType": "POST_PRODUCT_DATA", "marketplaceIds":["<marketplaceId>"], "inputFeedDocumentId":"<documentId>" }
Operational Advice
- Abstract marketplace IDs and currencies; avoid hard-coding NA/EU regions.
- Centralize signing; verify system clock skew to prevent SigV4 failures.
- Log original payloads and responses to reconcile with Seller Central.
Security
- Scope approvals are audited; store tokens securely.
- Use RDT only when necessary; purge PII promptly per policy.
Shopify Admin API
Shopify’s Admin API (REST and GraphQL) lets apps manage products, collections, orders, fulfillment, customers, and more on a per-store basis. Apps authenticate via OAuth and receive a store-scoped access token. Webhooks power near-real-time reactions.
Auth & Scopes
- Per-store OAuth install → Admin API access token.
- Least-privilege scopes (e.g.,
write_products
,read_orders
). - Webhook HMAC validation using the app’s shared secret.
What You Can Do
- Products/Variants: CRUD, images, metafields.
- Orders/Fulfillment: read/update, create fulfillments & tracking.
- Pricing: discounts, price rules, draft orders.
- Storefront: via Storefront GraphQL for headless builds.
Sample: GraphQL – Create a Product
POST https://<shop>.myshopify.com/admin/api/2024-10/graphql.json
X-Shopify-Access-Token: <token>
Content-Type: application/json
{
"query": "mutation($input: ProductInput!) { productCreate(input: $input) { product { id title handle } userErrors { field message } } }",
"variables": {
"input": {
"title": "Karathen API Tee",
"status": "ACTIVE",
"variants": [{ "price": "24.00" }]
}
}
}
Sample: REST – List Orders
GET https://<shop>.myshopify.com/admin/api/2024-10/orders.json?status=any
X-Shopify-Access-Token: <token>
pageInfo
in GraphQL) and respect checkpointing for large syncs. Always verify webhook HMACs.Fulfillment Flow (Typical)
- Order created → webhook (
orders/create
). - Rate shop cart at checkout via carrier APIs or a shipping app.
- Create fulfillment with tracking; update order status.
- Webhook (
fulfillments/create
) → notify customer.
Metafields & Extensibility
- Attach custom data to products, orders, customers.
- Use Admin UI extensions & app blocks for merchant-facing UI.
Clover API
Clover provides APIs to integrate with its Point-of-Sale (POS) ecosystem. It allows developers to access merchants’ data (with permission), process payments, manage orders, customers, inventory, and react to real-time events via webhooks.
Auth & Setup
- Auth: OAuth 2.0 with merchant-granted tokens.
- Scopes: Fine-grained (e.g.,
merchant:read
,inventory:write
). - Environment: Sandbox (developer) and Production (merchant live data).
Core Capabilities
- Process payments (credit, debit, contactless).
- Access order lifecycle (create, update, close orders).
- Manage inventory (items, modifiers, stock counts).
- Customer profiles (loyalty, marketing integration).
- Webhooks for payments, orders, employee activity.
Sample: Create an Order & Take Payment
# 1) Create Order
POST https://api.clover.com/v3/merchants/{mId}/orders
Authorization: Bearer <access_token>
Content-Type: application/json
{
"title": "Order #12345",
"total": 2400,
"state": "open"
}
# 2) Take Payment
POST https://api.clover.com/v3/merchants/{mId}/orders/{orderId}/payments
Authorization: Bearer <access_token>
Content-Type: application/json
{
"amount": 2400,
"tipAmount": 0,
"externalPaymentId": "ext-12345"
}
Typical Flow
- App installed → OAuth authorization → get merchant token.
- Create or update an order via API.
- Process payment → receive confirmation with IDs.
- Subscribe to webhooks for payment/order updates.
Common Gotchas
- Access tokens are merchant-specific; don’t reuse across merchants.
- Webhooks must validate Clover’s HMAC signature.
- Sandbox may not support all card features (test carefully).
- Some endpoints differ slightly by device type (Flex, Mini, Station).
Facebook Graph API
The Facebook Graph API powers Facebook Pages and Instagram Business integrations (via the Instagram Graph API). Apps use OAuth 2.0 to obtain user/page tokens and must pass App Review for many permissions.
Auth & Permissions
- OAuth 2.0 → user access token → exchange for long-lived token → page access token.
- Common permissions:
pages_manage_posts
,pages_read_engagement
,pages_manage_metadata
,instagram_basic
,instagram_content_publish
(IG). - App Review required for most publish/read scopes beyond development mode.
Core Capabilities
- Publish content to Facebook Pages & Instagram Business accounts.
- Read insights/engagement, manage comments, DMs (IG permissions required).
- Webhooks for subscriptions (e.g., comments, mentions, messages).
Sample: Publish a Photo to a Page
POST https://graph.facebook.com/v21.0/{page_id}/photos
Authorization: Bearer <PAGE_ACCESS_TOKEN>
Content-Type: application/x-www-form-urlencoded
url=https://example.com/image.jpg
&caption=Hello%20from%20Karathen%20API
X-Hub-Signature-256
; compute HMAC SHA-256 with the app secret and compare.
Typical Flow
- User logs in → get user token → exchange long-lived token.
- Retrieve Page list → request Page Access Token.
- Publish posts or media; subscribe to webhooks for comments/messages.
- Refresh tokens periodically; rotate app secret.
Gotchas
- Development mode limits data to app roles until App Review approval.
- Different endpoints/permissions for Instagram vs Facebook Pages.
- Rate limits & feature limits vary; handle errors with backoff.
LinkedIn API
LinkedIn’s Marketing Developer Platform enables organization-scoped posting, social engagement, ads, and analytics. Access is gated—many capabilities require partner approval and specific products enabled.
Auth & Scopes
- OAuth 2.0 Authorization Code → access/refresh tokens.
- Common scopes:
r_liteprofile
,w_member_social
,rw_organization_admin
,r_organization_social
. - Organization posting requires admin privileges for the organization.
Core Capabilities
- Create UGC posts (member or organization actor).
- Upload and attach images/videos to posts.
- Analytics and social actions (likes, comments) with proper scopes.
Sample: Create a Text UGC Post (Organization)
POST https://api.linkedin.com/v2/ugcPosts
Authorization: Bearer <access_token>
Content-Type: application/json
{
"author": "urn:li:organization:<orgId>",
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareCommentary": { "text": "Hello from Karathen API 👋" },
"shareMediaCategory": "NONE"
}
},
"visibility": { "com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC" }
}
Typical Flow
- OAuth login → verify org admin permissions.
- (Optional) Register and upload media, capture asset URNs.
- Create UGC post with org actor; monitor engagement.
- Use paging for analytics; respect throttling headers.
Gotchas
- Many APIs require partner application and approval.
- UGC vs Shares APIs differ; prefer UGC for newer features.
- Webhooks/notifications are limited—plan for polling in some cases.
TikTok API
TikTok offers APIs for login, basic profile, and (for Business Accounts) content publishing and analytics via its developer/marketing platforms. Posting capabilities are scoped and often restricted to Business accounts.
Auth & Access
- OAuth 2.0 with app-configured redirect URIs.
- Scopes vary by product (e.g., video upload/publish, basic profile, analytics).
- Some endpoints only for Business Accounts connected to your app.
Core Capabilities
- Initiate upload → transfer video bytes → publish post with caption/cover.
- Retrieve account/profile info and content performance (where allowed).
- Webhooks/Subscriptions available for certain events; otherwise poll.
Sample: Upload & Publish Video (Business)
# 1) Initialize upload session
POST https://open.tiktokapis.com/v2/video/upload/init/
Authorization: Bearer <access_token>
Content-Type: application/json
{ "source_info": { "source": "FILE" } }
# → returns upload_url + upload_id
# 2) Upload the file bytes to upload_url (PUT)
# 3) Publish
POST https://open.tiktokapis.com/v2/video/publish/
Authorization: Bearer <access_token>
Content-Type: application/json
{
"upload_id": "<upload_id>",
"caption": "Karathen API demo 🚀"
}
Typical Flow
- User connects Business account via OAuth.
- Initialize upload → send bytes → publish with caption/cover.
- Store returned IDs; fetch analytics later.
Gotchas
- Personal accounts have limited API posting support.
- Uploads can be large; use chunked transfer and retry logic.
- Regional restrictions & content policies may block publishing.
Mailchimp Marketing API
Mailchimp’s v3.0 Marketing API manages audiences (lists), contacts, campaigns, and automations.
Auth supports API keys (Basic) and OAuth 2.0 for connected apps. Most contact
operations are scoped to an audience (aka list_id
).
Auth & Setup
- Auth (API key):
Authorization: Basic
with base64 ofanystring:API_KEY
. Datacenter comes from key suffix (e.g.,us9
). - Auth (OAuth): Bearer token (
Authorization: Bearer <access_token>
). - Base URL:
https://<dc>.api.mailchimp.com/3.0
(replace<dc>
with your datacenter). - IDs: A “list” is an audience (
list_id
). Contacts are addressed bysubscriber_hash = MD5(lowercase(email))
.
Core Capabilities
- Audiences: create/update, fields (merge fields), interest groups.
- Members: upsert (subscribe/pending/unsubscribe/archive), tags.
- Campaigns: create, set content, send; templates; folders.
- Webhooks: subscribe to audience events (subscribe, profile updates, cleaned).
- Reports & Insights: campaign and audience-level metrics.
Sample: Upsert a Contact (Subscribe or Update)
# Upsert a member into an Audience (list)
# subscriber_hash = MD5(lowercase(email_address))
PUT https://<dc>.api.mailchimp.com/3.0/lists/{list_id}/members/{subscriber_hash}
Authorization: Basic <base64(anystring:API_KEY)>
Content-Type: application/json
{
"email_address": "ugarte16423@gmail.com",
"status_if_new": "subscribed", // "subscribed" | "pending" | "unsubscribed"
"status": "subscribed", // when updating existing
"merge_fields": {
"FNAME": "Raul",
"LNAME": "Ugarte Zurdo",
"PHONE": "+1 813 555 0000",
"ODOO": "12345" // custom merge field tag for "Odoo ID"
},
"tags": ["Customer", "Odoo"]
}
ODOO
).
List / Manage Merge Fields
# 1) List merge fields to discover tags (e.g., FNAME, LNAME, ODOO)
GET https://<dc>.api.mailchimp.com/3.0/lists/{list_id}/merge-fields
Authorization: Basic <base64(anystring:API_KEY)>
# 2) Create a custom merge field "Odoo ID" with tag ODOO (example)
POST https://<dc>.api.mailchimp.com/3.0/lists/{list_id}/merge-fields
Authorization: Basic <base64(anystring:API_KEY)>
Content-Type: application/json
{
"name": "Odoo ID",
"type": "text",
"tag": "ODOO",
"required": false,
"public": true
}
Create an Audience (List)
POST https://<dc>.api.mailchimp.com/3.0/lists
Authorization: Basic <base64(anystring:API_KEY)>
Content-Type: application/json
{
"name": "Karathen Customers",
"permission_reminder": "You are receiving this because you opted in at checkout.",
"email_type_option": true,
"contact": {
"company": "Karathen",
"address1": "500 Main St",
"city": "Tampa",
"state": "FL",
"zip": "33602",
"country": "US"
},
"campaign_defaults": {
"from_name": "Karathen",
"from_email": "no-reply@karathen.com",
"subject": "",
"language": "en"
}
}
Webhooks: Receive Audience Events
POST https://<dc>.api.mailchimp.com/3.0/lists/{list_id}/webhooks
Authorization: Basic <base64(anystring:API_KEY)>
Content-Type: application/json
{
"url": "https://staging-api.karathen.com/mailchimp/webhook",
"events": {
"subscribe": true,
"unsubscribe": true,
"profile": true,
"cleaned": true,
"upemail": true,
"campaign": true
},
"sources": { "user": true, "admin": true, "api": true }
}
Typical Contact Flow
- Ensure merge fields exist (e.g.,
ODOO
custom field). - Compute
subscriber_hash
→PUT
member withstatus_if_new
. - Apply tags for segments; update profile fields as needed.
- Listen to webhooks for changes (unsubscribed, cleaned, profile updates).
Common Gotchas
- Archived vs Deleted: Archived contacts can usually be re-subscribed via
PUT
withstatus
/status_if_new
. Permanently deleted contacts must re-opt-in via a form; API will reject. - “Signed up to a lot of lists recently”: Anti-abuse throttle—try later or use double opt-in (
pending
), or have the user confirm via your hosted form. - Field Tags: Use the merge field tag (e.g.,
ODOO
), not the display name (“Odoo ID”). Discover via/merge-fields
. - Status transitions: Some transitions require
pending
+ confirmation depending on account settings and compliance.