JUHE API Marketplace
Comprehensive Documentation

API Documentation

Everything you need to integrate and use our APIs effectively with guides, references, and examples

Basic Integration

4 min read

Welcome to the Basic Integration guide for JUHE API! This section covers the essential concepts and techniques you need to successfully integrate our APIs into your applications.

API Authentication

All JUHE API endpoints require authentication using an API key. There are two ways to include your API key in requests:

Query Parameter

<https://hub.juheapi.com/endpoint?key=YOUR_API_KEY>

Authorization Header

Authorization: Bearer YOUR_API_KEY

🔐 Security Tip: Using the Authorization header is generally more secure than including your API key in the URL, especially when your requests might be logged or cached.

💡 Pro Tip: Set up your API key as an environment variable in your development environment to avoid hardcoding it in your application.

Request Structure

JUHE API follows RESTful principles for all endpoints. Here's what you need to know:

Base URL

All API requests start with the base URL:

<https://hub.juheapi.com/>

API Paths

Each API category has its own path:

  • Weather API: /weather/v1
  • SMS Verification: /sms
  • IP Geolocation: /geo/ip
  • And so on...

HTTP Methods

JUHE API supports the following HTTP methods:

  • GET: Retrieve data (most common)
  • POST: Create or process data
  • PUT: Update existing data
  • DELETE: Remove data

Headers

For most requests, you'll want to include these headers:

Content-Type: application/json
Accept: application/json

Response Handling

Success Responses

Successful responses generally follow this structure:

{
  "status": "success",
  "data": {
    // The actual response data will be here
  }
}

Error Responses

Error responses follow this structure:

{
  "status": "error",
  "code": "ERROR_CODE",
  "message": "A human-readable explanation of what went wrong"
}

🧩 Fun Exercise: Create a simple error handling wrapper function that checks for errors in API responses and handles them gracefully. This will save you time in the long run!

Common Error Codes

Error CodeDescriptionResolution
INVALID_KEYThe API key is invalid or expiredCheck that your API key is correct and active
RATE_LIMIT_EXCEEDEDYou've exceeded your plan's rate limitWait before retrying or upgrade your plan
MISSING_PARAMETERA required parameter is missingCheck the API documentation for required parameters
INVALID_FORMATRequest data is formatted incorrectlyEnsure your request follows the expected format

Rate Limits

To ensure fair usage and system stability, JUHE API implements rate limiting:

  • Free tier: 10 requests per minute
  • Paid tier: 1000 requests per minute
  • Enterprise tier: Custom limits available

When you exceed your rate limit, you'll receive a 429 Too Many Requests response with a RATE_LIMIT_EXCEEDED error code.

⏱️ Time-Saving Tip: Implement exponential backoff in your application for rate limit handling. Start with a small delay and increase it for each retry.

Client Libraries

If you're using a language or framework without an official SDK, here are some recommended libraries for HTTP requests:

LanguageRecommended Library
JavaScriptAxios, isomorphic-fetch
PythonRequests
JavaOkHttp, Apache HttpClient
PHPGuzzle
RubyHTTParty
Gonet/http

Webhook Integration

Some JUHE APIs support webhooks for asynchronous event notifications. To use webhooks:

  1. Register a publicly accessible URL in your JUHE API dashboard
  2. Configure which events should trigger webhook calls
  3. Implement an endpoint at your URL to receive and process webhook data
  4. Verify webhook signatures to ensure requests are genuine

Here's a simple example of a Node.js webhook receiver:

const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const crypto = require('crypto');

app.use(bodyParser.json());

app.post('/webhook/juhe', (req, res) => {
  // Verify signature
  const signature = req.headers['x-juhe-signature'];
  const payload = JSON.stringify(req.body);
  const expectedSignature = crypto
    .createHmac('sha256', 'YOUR_WEBHOOK_SECRET')
    .update(payload)
    .digest('hex');

  if (signature !== expectedSignature) {
    return res.status(401).send('Invalid signature');
  }

  // Process the webhook data
  console.log('Received webhook:', req.body);

  // Respond to confirm receipt
  res.status(200).send('Webhook received');
});

app.listen(3000, () => {
  console.log('Webhook server running on port 3000');
});

Next Steps

Now that you understand the basics of integrating with JUHE API, you're ready to:

  1. Explore Advanced Topics for more sophisticated integration techniques
  2. Check out Integration Examples for complete code samples
  3. Learn about Best Practices for efficient and reliable API usage

🚀 Challenge: Create a simple dashboard that displays your API usage statistics. This will help you monitor your consumption and stay within your rate limits!