Skip to content

abdipr/myinstants-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

32 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MyInstants

MyInstants REST API

PHP Version Deployed on Vercel License MIT PRs Welcome

A RESTful API for scraping and retrieving sound data from the MyInstants website. This API provides endpoints for retrieving information about sounds, including titles, URLs, descriptions, tags, favorites, views, and uploader details.

✨ Features

  • ⚑ Ultra Fast: Powered by Vercel Edge Caching (s-maxage=3600) for ~0ms response times on cached requests.
  • πŸš€ Serverless Ready: Native deployment to Vercel without tweaking. Uses separate serverless functions for maximum efficiency.
  • 🌐 CORS Enabled: Ready to be consumed directly from frontend web applications (React, Vue, etc) without cross-origin issues.
  • 🎯 Reliable Error Handling: Returns proper HTTP status codes (e.g., 404, 400) instead of just 200 OK.

Table of Contents

πŸš€ Getting Started

Requirements

  • PHP 7.4 or higher
  • simple_html_dom.php library for HTML parsing
  • curl extension enabled in php.ini

Installation

  1. Clone the repository to your server:

    git clone https://github.com/abdipr/myinstants-api.git
    cd myinstants-api
  2. Download and include simple_html_dom.php in the project directory.

  3. Local Development (No Apache/Nginx required): You can run the API locally using PHP's built-in web server. This project includes a router.php file that perfectly simulates Vercel's serverless routing environment, allowing you to access endpoints without the .php extension.

    php -S localhost:8000 router.php

    Now you can access the API locally (e.g., http://localhost:8000/best?q=id).

  4. Deploy to Vercel: Deploying is simple. Click the button below to deploy this repository directly to your Vercel account.
    Deploy with Vercel

❇️ Reference

Endpoints

Base URL: https://myinstants-api.vercel.app

Request Response Parameter
GET /trending Trending based region q
GET /search Search a sound q
GET /detail The sound details id
GET /recent Recently uploaded sounds
GET /best Best of all time sounds q
GET /uploaded User's uploaded sounds username
GET /favorites User's favorite sounds username

Request Parameters

Parameter Description
q Search query or region
username User's username
id Sound's Unique ID

Response Example

A typical successful response (HTTP 200) will return a JSON object like this:

{
  "status": 200,
  "author": "abdipr",
  "data": [
    {
      "id": "vine-boom-sound-70972",
      "title": "VINE BOOM SOUND",
      "url": "https://www.myinstants.com/en/instant/vine-boom-sound-70972/",
      "mp3": "https://www.myinstants.com/media/sounds/vine-boom.mp3"
    }
  ]
}

Note: For the /detail endpoint, the data object will contain extra fields like description, tags, favorites, views, and uploader.

πŸ’₯ Error Handling

All errors return JSON objects with an appropriate HTTP status code (e.g., 404, 400) and a message explaining the issue.

  • 404 Error:
    • When the page is not found or an invalid endpoint is accessed.
    {
      "status": 404,
      "author": "abdipr",
      "message": "Endpoint not found"
    }

🌐 Examples

Example 1: Get Trending Sounds by Region

GET https://myinstants-api.vercel.app/trending?q=id

Example 2: Search Sounds by Query

GET https://myinstants-api.vercel.app/search?q=laugh

Example 3: Get Sound Details by ID

GET https://myinstants-api.vercel.app/detail?id=akh-26815

Example 4: Get Recently Uploaded Sounds

GET https://myinstants-api.vercel.app/recent

Example 5: Get Best of All Time Sounds

Retrieve a list of the most popular sounds of all time based on a specified region:

GET https://myinstants-api.vercel.app/best?q=id

Example 6: Get User's Uploaded Sounds

GET https://myinstants-api.vercel.app/uploaded?username=hellmouz

Example 7: Get User's Favorite Sounds

GET https://myinstants-api.vercel.app/favorites?username=hellmouz

🌱 Contributing

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a feature branch: git checkout -b feature-name.
  3. Commit your changes: git commit -m 'Add feature'.
  4. Push to the branch: git push origin feature-name.
  5. Submit a pull request.

✨ Support

If you like this project, please star on this repository, thank you ⭐
You can support me by:
Trakteer Saya Buy Me A Coffee

βš–οΈ License

This project is licensed under the MIT License. See the LICENSE file for more information.

⚠️ Disclaimer

The sounds contained in this API are obtained from the original MyInstants website by web scraping. Developers using this API must follow the applicable regulations by mentioning this project or the official owner in their projects and are prohibited from abusing this API for personal benefits.

⬆️ Back to Top

About

MyInstants Unofficial JSON REST API. A RESTful API for scraping and retrieving sound data from the MyInstants website. This API provides endpoints for retrieving information about sounds, including titles, URLs, descriptions, tags, favorites, views, and uploader details.

Topics

Resources

License

Stars

26 stars

Watchers

1 watching

Forks

Releases

No releases published

Contributors

Languages