Couponeer Product API

Welcome to the **Couponeer API** documentation! This guide provides an overview of how to interact with our API, located at `https://couponeer.alreflections.net/api.php`. The API enables users to fetch affiliate product information from various RSS feeds based on search criteria. ## Base URL ``` https://couponeer.alreflections.net/api.php ``` Below are examples of how to access the **Couponeer API** using different technologies and programming languages. ### 1. **Accessing the API with cURL (Command Line)** You can use `cURL` to make a request to the Couponeer API directly from the command line. #### Example Request: ```bash curl "https://couponeer.alreflections.net/api.php?client=app&q=discounts&coupon=123" ``` This will send a `GET` request to the API with the specified query parameters. ### 2. **Accessing the API with JavaScript (Fetch API)** If you're working with JavaScript in a browser or Node.js, you can use the `fetch` API to make a request. #### Example Request: ```javascript fetch('https://couponeer.alreflections.net/api.php?client=app&q=discounts&coupon=123') .then(response => response.json()) .then(data => { console.log(data); }) .catch(error => { console.error('Error fetching data:', error); }); ``` ### 3. **Accessing the API with Python (Requests Library)** For Python developers, you can use the `requests` library to interact with the API. #### Example Request: First, make sure you have the `requests` library installed: ```bash pip install requests ``` Then, use the following code: ```python import requests url = "https://couponeer.alreflections.net/api.php" params = { "client": "app", "q": "discounts", "coupon": "123" } response = requests.get(url, params=params) if response.status_code == 200: data = response.json() print(data) else: print("Error:", response.status_code) ``` ### 4. **Accessing the API with Node.js (Axios Library)** You can use the `axios` library in Node.js for making HTTP requests. First, install `axios`: ```bash npm install axios ``` Then, you can make a GET request like this: #### Example Request: ```javascript const axios = require('axios'); const url = 'https://couponeer.alreflections.net/api.php'; const params = { client: 'app', q: 'discounts', coupon: '123' }; axios.get(url, { params }) .then(response => { console.log(response.data); }) .catch(error => { console.error('Error fetching data:', error); }); ``` ### 5. **Accessing the API with PHP (cURL)** In PHP, you can use `cURL` to make a GET request to the API. #### Example Request: ```php ``` ### 6. **Accessing the API with Java (HttpURLConnection)** In Java, you can use `HttpURLConnection` to make a GET request to the Couponeer API. #### Example Request: ```java import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class CouponeerAPI { public static void main(String[] args) { try { String url = "https://couponeer.alreflections.net/api.php?client=app&q=discounts&coupon=123"; HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); connection.setRequestMethod("GET"); BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); String inputLine; StringBuilder response = new StringBuilder(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); // Output response System.out.println(response.toString()); } catch (Exception e) { e.printStackTrace(); } } } ``` ### 7. **Accessing the API with Ruby (Net::HTTP)** Ruby provides `Net::HTTP` for making HTTP requests. Here's how you can access the Couponeer API. #### Example Request: ```ruby require 'net/http' require 'json' require 'uri' uri = URI.parse("https://couponeer.alreflections.net/api.php?client=app&q=discounts&coupon=123") response = Net::HTTP.get_response(uri) if response.is_a?(Net::HTTPSuccess) data = JSON.parse(response.body) puts data else puts "Error: #{response.code}" end ``` ### 8. **Accessing the API with Postman** If you prefer to test the API manually, **Postman** is a great tool for sending HTTP requests. Here's how you can set it up: 1. Open **Postman**. 2. Select the **GET** method. 3. Enter the URL: `https://couponeer.alreflections.net/api.php?client=app&q=discounts&coupon=123` 4. Hit the **Send** button. Postman will send the request and display the response in the window below. As demonstrated, you can access the Couponeer API using different technologies, including: - **cURL** (command line) - **JavaScript** (using the `fetch` API) - **Python** (using `requests`) - **Node.js** (using `axios`) - **PHP** (using `cURL`) - **Java** (using `HttpURLConnection`) - **Ruby** (using `Net::HTTP`) - **Postman** (for manual testing) Each method shows how to make a simple GET request to the Couponeer API, retrieve the product data, and handle the response. You can choose any of these methods depending on your project or environment. ## Endpoint ### `GET /api.php` This endpoint allows you to retrieve affiliate product information using query parameters. ## Query Parameters | **Parameter** | **Type** | **Required** | **Description** | |---------------|----------|--------------|-----------------| | `client` | string | Yes | Specifies the type of client making the request. Acceptable values: `app`. | | `coupon` | int | No | The coupon ID to append to product links. | | `name` | string | No | The name of the client or application. Defaults to `Couponeer` if not provided. | | `q` | string | No | The search query to filter products from the RSS feeds. | ## Example Request To search for products related to a term (e.g., "discounts"), you can make a GET request like the following: ``` GET https://couponeer.alreflections.net/api.php?client=app&q=discounts&coupon=123 ``` ## Response Format The API returns a **JSON** object with the structure described below: ```json { "products": [ { "title": "Product Title 1", "description": "Description of Product 1.", "link": "https://example.com/product1?coupon=123", "image": "https://example.com/image1.jpg" }, { "title": "Product Title 2", "description": "Description of Product 2.", "link": "https://example.com/product2?coupon=123", "image": "https://example.com/image2.jpg" } ], "error": "Error message if applicable" } ``` ### Response Fields | **Field** | **Type** | **Description** | |---------------|-----------|-----------------| | `products` | array | A list of product objects that match the search criteria. Each product contains: | | `title` | string | The product title. | | `description` | string | A brief description of the product. | | `link` | string | The URL to the product page, including the coupon code if provided. | | `image` | string | The URL of the product image. | ## Example Response Here is an example of a successful response: ```json { "products": [ { "title": "Amazing Discount on Shoes", "description": "Get 50% off on all shoes this weekend!", "link": "https://example.com/shoes?coupon=123", "image": "https://example.com/images/shoes.jpg" }, { "title": "Summer Sale on T-Shirts", "description": "Buy 2 T-Shirts and get 1 free!", "link": "https://example.com/tshirts?coupon=123", "image": "https://example.com/images/tshirts.jpg" } ] } ``` ## Notes - **Client Parameter**: The `client` parameter is required. Ensure it is set correctly to either `affiliate` or `app` to access the relevant functionality. - **Coupon Parameter**: The `coupon` parameter is optional. If provided, it will append the coupon code to the product URLs. - **Search Query**: The `q` parameter allows you to filter products by a specific search term. - **Blogspot**: If specified, the `blogspot` parameter filters products to include those associated with a particular Blogspot blog. ## Conclusion The **Couponeer API** provides an easy-to-use interface for accessing affiliate product information from multiple RSS feeds. By utilizing the available query parameters, users can efficiently retrieve products relevant to their search criteria. If you have any questions or encounter issues, feel free to contact our support team. (Email: support@alreflections.net) Happy coding!

Post a Comment

0 Comments