Instagram API
Instagram API
2 API
Example
import requests

url = "URL"
response = requests.get(url).json()
print(response)
$url = "URL";
$response = file_get_contents($url);
$data = json_decode($response, true);
print_r($data);
const fetch = require('node-fetch');

const url = "URL";
fetch(url)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.log(error));
const url = "URL";
fetch(url)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.log(error));
import React, { useEffect } from 'react';

function App() {
  useEffect(() => {
    const url = "URL";
    fetch(url)
      .then(response => response.json())
      .then(data => console.log(data))
      .catch(error => console.log(error));
  }, []);

  return (
    <div>
      {/* Another component here */}
    </div>
  );
}

export default App;
<template>
  <div>
    <!-- Another component here -->
  </div>
</template>

<script>
import axios from 'axios';

export default {
  mounted() {
    const url = "URL";
    axios.get(url)
      .then(response => {
        console.log(response.data);
      })
      .catch(error => {
        console.log(error);
      });
  }
}
</script>
require 'net/http'
require 'json'

url = "URL"
uri = URI(url)
response = Net::HTTP.get(uri)
data = JSON.parse(response)
puts data
package main

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {
	url := "URL"
	response, err := http.Get(url)
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	defer response.Body.Close()

	body, err := ioutil.ReadAll(response.Body)
	if err != nil {
		fmt.Println("Error:", err)
		return
	}

	var data interface{}
	err = json.Unmarshal(body, &data)
	if err != nil {
		fmt.Println("Error:", err)
		return
	}

	fmt.Println(data)
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    public static void main(String[] args) {
        String url = "URL";
        try {
            URL apiUrl = new URL(url);
            HttpURLConnection connection = (HttpURLConnection) apiUrl.openConnection();
            connection.setRequestMethod("GET");

            int responseCode = connection.getResponseCode();
            if (responseCode == HttpURLConnection.HTTP_OK) {
                BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                StringBuilder response = new StringBuilder();
                String line;
                while ((line = reader.readLine()) != null) {
                    response.append(line);
                }
                reader.close();

                String jsonResponse = response.toString();
                System.out.println(jsonResponse);
            } else {
                System.out.println("Error: " + responseCode);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
#include <iostream>
#include <curl/curl.h>
#include <jsoncpp/json/json.h>

size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* response) {
    size_t totalSize = size * nmemb;
    response->append(static_cast<char*>(contents), totalSize);
    return totalSize;
}

int main() {
    std::string url = "URL";

    CURL* curl = curl_easy_init();
    if (curl) {
        std::string response;

        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);

        CURLcode res = curl_easy_perform(curl);
        if (res == CURLE_OK) {
            Json::Value data;
            Json::CharReaderBuilder reader;
            std::istringstream jsonStream(response);
            std::string parseErrors;

            if (Json::parseFromStream(reader, jsonStream, &data, &parseErrors)) {
                std::cout << data << std::endl;
            } else {
                std::cout << "Failed to parse JSON: " << parseErrors << std::endl;
            }
        } else {
            std::cout << "Error: " << curl_easy_strerror(res) << std::endl;
        }

        curl_easy_cleanup(curl);
    }

    return 0;
}
Get User Information

Retrieve all Instagram channel information, not including email and password.

https://forestapi.vercel.app/api/instagram/user/<username>

Output :

{
  "status": true,
  "username": "Account Username",
  "name": "Account Name",
  "followers": "Total Account Followers",
  "following": "Total Account Following",
  "posts": "Total Account Posts",
  "image_url": "Account Profile Photo"
}
Get Photo Information

Take all the photo posting information on the account.

https://forestapi.vercel.app/api/instagram/photo/<id>

Output :

{
  "status": true,
  "author": "Photo Author",
  "description": "Photo Description",
  "likes": "Total Photo Likes",
  "comments": "Total Photo Comments",
  "photo_url": "Photo URL"
}