Instagram API for Go.
Clean example request for the media downloader endpoint. Replace YOUR API and the media URL, then run the code.
Checking
Clean example request for the media downloader endpoint. Replace YOUR API and the media URL, then run the code.
package main
import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"net/url"
)
const (
apiKey = "YOUR API"
videoURL = "URL INSTAGRAM"
endpoint = "https://senpai-bot.store/instagramdl"
)
type Result struct {
Caption string `json:"caption"`
Comments int `json:"comments"`
Created string `json:"created"`
Duration float64 `json:"duration"`
FullName string `json:"full_name"`
Likes int `json:"likes"`
Picture interface{} `json:"picture"`
PostType string `json:"post_type"`
PostURL string `json:"post_url"`
Poster string `json:"poster"`
Private bool `json:"private"`
SlidePost bool `json:"slide_post"`
Type string `json:"type"`
Username string `json:"username"`
Verified bool `json:"verified"`
}
type ApiResponse struct {
Code int `json:"code"`
Result Result `json:"result"`
}
func main() {
encodedVideoURL := url.QueryEscape(videoURL)
getData := fmt.Sprintf("%s?apikey=%s&url=%s", endpoint, apiKey, encodedVideoURL)
resp, err := http.Get(getData)
if err != nil {
log.Fatalf("Error making request: %v", err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatalf("Error reading response: %v", err)
}
var response ApiResponse
if err := json.Unmarshal(body, &response); err != nil {
log.Fatalf("Error parsing JSON: %v", err)
}
if response.Code != 200 {
log.Fatalf("API returned error code: %d", response.Code)
}
r := response.Result
fmt.Println("Username :", r.Username)
fmt.Println("Full Name :", r.FullName)
fmt.Println("Caption :", r.Caption)
fmt.Println("Post URL :", r.PostURL)
fmt.Println("Post Type :", r.PostType)
fmt.Println("Media Type :", r.Type)
fmt.Println("Duration :", r.Duration)
fmt.Println("Likes :", r.Likes)
fmt.Println("Comments :", r.Comments)
fmt.Println("Created :", r.Created)
fmt.Println("Poster URL :", r.Poster)
if r.Picture != nil {
fmt.Println("Picture :", r.Picture)
} else {
fmt.Println("Picture : (null)")
}
fmt.Println("Private :", r.Private)
fmt.Println("Slide Post :", r.SlidePost)
fmt.Println("Verified :", r.Verified)
}