Build Your Movie Site with Free Data from TheMoviesKing.com API — Step by Step

How to Use TheMoviesKing.com API: A Complete Guide with Examples


TheMoviesKing.com offers a powerful and easy-to-use API to access movie data, including detailed metadata, encrypted download and watch links, and filtering and sorting options. Whether you are building a movie website, streaming app, or a data-driven entertainment platform, this API can be a valuable tool to provide dynamic content.

In this comprehensive guide, you will learn:

  • How to authenticate your API requests with your API key
  • How to fetch all posts with filters, sorting, and pagination
  • How to get detailed data of a single post
  • How to handle encrypted download and watch URLs
  • How to consume the API using PHP cURL with a practical example

1. Getting Started: Your API Key

To use TheMoviesKing.com API, you first need your API key. This key authenticates your requests and ensures you have access to the data.

Your API key is:

3de5c8626858a0a0c8872ae5d1bdce8222397e89c00f363595595f726bb828ed

How to use your API key:
Simply append the API key as a query parameter in all your API URLs:

?api_key=3de5c8626858a0a0c8872ae5d1bdce8222397e89c00f363595595f726bb828ed

2. Fetch All Movie Posts

The primary endpoint to get posts (movies, series, or other content) is:

https://themoviesking.online/api/posts?api_key=YOUR_API_KEY

Example:

https://themoviesking.online/api/posts?api_key=3de5c8626858a0a0c8872ae5d1bdce8222397e89c00f363595595f726bb828ed

This returns a list of posts with metadata like title, year, type, language, tags, posters, and encrypted tokens for downloads and streaming.

3. Filtering Results

You can refine your query results with optional filters:

Filter Description Example
type Filter by content type (movie, series) &type=movie
lang Filter by language code (en, hi, etc.) &lang=en
year Filter by release year &year=2025
query Search by keyword &query=avengers

Example: Fetch English movies released in 2025 containing the word "action":

https://themoviesking.online/api/posts?api_key=3de5c8626858a0a0c8872ae5d1bdce8222397e89c00f363595595f726bb828ed&type=movie&lang=en&year=2025&query=action

4. Sorting and Pagination

You can sort results by any field, and control the order (ASC or DESC):

Parameter Description Default Value
sort Field to sort by created_at
order Sort order (ASC/DESC) DESC

Example: Sort posts by title ascending

https://themoviesking.online/api/posts?api_key=YOUR_API_KEY&sort=title&order=ASC

5. Fetch a Single Post by ID

To get detailed information about one specific post, including all metadata, tags, images, and encrypted download/watch tokens, use:

https://themoviesking.online/api/post/POST_ID?api_key=YOUR_API_KEY

Example: Fetch post with ID 123

https://themoviesking.online/api/post/123?api_key=3de5c8626858a0a0c8872ae5d1bdce8222397e89c00f363595595f726bb828ed

6. Secure Download and Watch Links

Download and watch links are not given as plain URLs but as encrypted tokens for security.

Use this endpoint to decode the token into an actual URL:

https://themoviesking.online/api/url?token=YOUR_ENCRYPTED_TOKEN

Example:

If you get this token from the post data:

"download_link": "abc123encryptedtoken"

Call:

https://themoviesking.online/api/url?token=abc123encryptedtoken

The API will respond with the real download URL.

7. JSON Response Format

Here’s what a typical JSON response looks like when fetching posts:

{
  "status": "success",
  "count": 10,
  "total": 10545,
  "page": 1,
  "limit": 10,
  "sort": "created_at DESC",
  "timestamp": "2025-05-24T14:19:32+06:00",
  "posts": [
    {
      "id": 123,
      "title": "Avengers: Endgame",
      "year": 2019,
      "type": "movie",
      "lang": "en",
      "description": "The final battle of the Avengers to undo the damage caused by Thanos.",
      "tags": ["action", "superhero", "adventure"],
      "poster": "https://themoviesking.online/images/avengers_endgame.jpg",
      "download_link": "encrypted_token_here",
      "watch_link": "encrypted_token_here",
      "created_at": "2019-04-26T12:00:00+00:00"
    }
    // More posts...
  ]
}

8. PHP Example: Fetch and Display Posts Using cURL

Here’s a simple PHP script demonstrating how to fetch posts using cURL and print the results:

<?php
// API endpoint with your API key and optional filters
$url = "https://themoviesking.online/api/posts?api_key=3de5c8626858a0a0c8872ae5d1bdce8222397e89c00f363595595f726bb828ed&type=movie&lang=en&sort=created_at&order=DESC";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($httpCode === 200) {
    $data = json_decode($response, true);

    if ($data['status'] === 'success') {
        echo "<h2>Showing {$data['count']} of {$data['total']} Movies</h2>";

        foreach ($data['posts'] as $post) {
            echo "<div style='border:1px solid #ccc; padding:10px; margin-bottom:10px;'>";
            echo "<h3>{$post['title']} ({$post['year']})</h3>";
            echo "<img src='{$post['poster']}' alt='{$post['title']}' style='max-width:150px; float:left; margin-right:15px;' />";
            echo "<p>{$post['description']}</p>";
            echo "<p><strong>Tags:</strong> " . implode(', ', $post['tags']) . "</p>";
            echo "<div style='clear:both;'></div>";
            echo "</div>";
        }
    } else {
        echo "API Error: " . ($data['message'] ?? 'Unknown error');
    }
} else {
    echo "API Request failed. HTTP Code: $httpCode";
}
?>

9. Best Practices and Tips

  • Keep your API key secret: Never expose it in public client-side code.
  • Implement caching: Cache API results locally for better performance and reduced API load.
  • Respect rate limits: If there is a rate limit, avoid excessive API calls.
  • Use pagination: Always paginate when fetching large datasets to avoid timeouts.
  • Handle errors: Gracefully handle HTTP errors and invalid responses.
  • Secure token usage: Always fetch actual URLs for downloads and watches via the /url endpoint using tokens.

10. What Can You Build?

Using TheMoviesKing.com API, you can quickly build:

  • A dynamic movie catalog website with search and filters
  • Mobile apps for streaming and downloading movies
  • Chatbots that provide movie info on demand
  • Automated movie blogs with fresh content
  • Recommendation engines based on genres, languages, and years

Conclusion

TheMoviesKing.com API is an excellent resource for developers looking to add rich movie content to their projects. With secure tokenized download/watch links, flexible filtering, and detailed metadata, it empowers you to create engaging user experiences.

If you have any questions or need help integrating, just ask!

এই পোস্টটি পরিচিতদের সাথে শেয়ার করুন

পূর্বের পোস্ট দেখুন পরবর্তী পোস্ট দেখুন
এই পোস্টে এখনো কেউ মন্তব্য করে নি
মন্তব্য করতে এখানে ক্লিক করুন

অর্ডিনারি আইটির নীতিমালা মেনে কমেন্ট করুন। প্রতিটি কমেন্ট রিভিউ করা হয়।

comment url