Last updated

Authentication

This page covers authentication requirements for all API calls within Influencer Hero.

Overview

You will need to include your API key in the header of every request you send to the Influencer Hero API. If you don’t yet have access or don’t have an API key, please contact your account administrator or Influencer Hero support.

Obtaining an API Key

If you already have API access, you can find your API key under:

https://app.influencer-hero.com/api

If you need assistance or do not see the option to generate an API key, please reach out to your account administrator or Influencer Hero support.

Using Your API Key

  1. Set the request header “X-API-KEY” to your personal API key.
  2. Make sure you provide the key in all requests to ensure you have the correct privileges.
  3. Only use your personal API key. If you suspect your key has been compromised, contact your account manager to rotate (re-generate) it immediately.

Base URL

All requests should be made to:
https://api.influencer-hero.com

Any calls to different domains or subdomains might return an error or may be reserved for testing purposes.

Example Request

Below are code examples in multiple languages demonstrating how to authenticate and send a GET request to the Influencer Hero API.

cURL

curl -X GET \
  -H "Content-Type: application/json" \
  -H "X-API-KEY: YOUR_API_KEY_HERE" \
  https://api.influencer-hero.com/v1/account/hello

or for a POST request with JSON data:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "X-API-KEY: YOUR_API_KEY_HERE" \
  -d '{"influencer_list": ["test@example.com"], "brand_id": 1001}' \
  https://api.influencer-hero.com/v1/search/identify_influencers

Python

import requests

url = "https://api.influencer-hero.com/v1/account/hello"
headers = {
    "Content-Type": "application/json",
    "X-API-KEY": "YOUR_API_KEY_HERE"
}

response = requests.get(url, headers=headers)

print(response.status_code)
print(response.json())  # or response.text if not JSON

Node.js (Axios)

const axios = require('axios');

const url = 'https://api.influencer-hero.com/v1/account/hello';
const apiKey = 'YOUR_API_KEY_HERE';

axios.get(url, {
  headers: {
    'Content-Type': 'application/json',
    'X-API-KEY': apiKey
  }
})
.then(response => {
  console.log(response.data);
})
.catch(error => {
  console.error(error);
});

Ruby

require 'net/http'
require 'json'
 
uri = URI('https://api.influencer-hero.com/v1/account/hello')
req = Net::HTTP::Get.new(uri)
req['Content-Type'] = 'application/json'
req['X-API-KEY'] = 'YOUR_API_KEY_HERE'

res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(req)
end

puts "Response Code: #{res.code}"
puts "Response Body: #{res.body}"

Java (OkHttp)

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;

public class ApiExample {
    public static void main(String[] args) {
        OkHttpClient client = new OkHttpClient();

        Request request = new Request.Builder()
            .url("https://api.influencer-hero.com/v1/account/hello")
            .header("Content-Type", "application/json")
            .header("X-API-KEY", "YOUR_API_KEY_HERE")
            .build();

        try (Response response = client.newCall(request).execute()) {
            if (response.isSuccessful()) {
                System.out.println("Response Code: " + response.code());
                System.out.println("Response Body: " + response.body().string());
            } else {
                System.out.println("Request failed. HTTP Code: " + response.code());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

C# (HttpClient)

using System;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        var client = new HttpClient();
        
        // Set headers
        client.DefaultRequestHeaders.Add("X-API-KEY", "YOUR_API_KEY_HERE");
        // For JSON, you generally set this per-request instead of a default, but shown here for simplicity:
        client.DefaultRequestHeaders.Add("Content-Type", "application/json");

        var url = "https://api.influencer-hero.com/v1/account/hello";
        var response = await client.GetAsync(url);

        Console.WriteLine("Response Code: " + (int)response.StatusCode);
        var responseBody = await response.Content.ReadAsStringAsync();
        Console.WriteLine("Response Body: " + responseBody);
    }
}

Go

package main

import (
    "fmt"
    "io"
    "log"
    "net/http"
)

func main() {
    client := &http.Client{}

    req, err := http.NewRequest("GET", "https://api.influencer-hero.com/v1/account/hello", nil)
    if err != nil {
        log.Fatal(err)
    }

    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("X-API-KEY", "YOUR_API_KEY_HERE")

    resp, err := client.Do(req)
    if err != nil {
        log.Fatal(err)
    }
    defer resp.Body.Close()

    body, err := io.ReadAll(resp.Body)
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println("Response Code:", resp.StatusCode)
    fmt.Println("Response Body:", string(body))
}

(You can adapt these examples for your specific use case or preferred HTTP library.)

Request and Response Format

  • All requests and responses are in JSON format.
  • Typical HTTP methods include GET, POST, PUT, and DELETE for various endpoints.
  • If your request does not contain a valid API key, you will receive an HTTP 401 Unauthorized response.

Best Practices and Security

  • Store your key securely and do not commit it to source control.
  • Limit the key’s scope by using environment variables or appropriate credential storage solutions.
  • If you suspect your credentials are compromised, contact your account manager to create a new API key immediately.

If you have additional questions about authentication, or you encounter issues using your existing key, please contact Influencer Hero support.