API docs
Table of Contents
- API Authorization
- GET /api/public/profile/{profileId} (Get profile)
- PUT /api/public/profile/{profileId} (Update profile)
- DELETE /api/public/profile/{profileId} (Delete profile)
API Authorization
In order to use ModHeader API, you must first create an API key. Do NOT share you API key with people.
Once you have obtained an API key, you can authenticate to the APIs below using the Authorization
request header as followed:
Authorization: Bearer {API_key}
GET
/api/public/profile/{profileId}
(Get profile)
Get the profile.
You can find the profile ID from the exported profile URL. The profile ID is the last part of your profile URL.
Responses
http code content-type response 200
application/json
The profile and its metadata. The actual profile is inside the profile
field in the response.400
text/plain
The request is invalid. Please make sure that the POST body is correct. 401
text/plain
Invalid API key
Example Javascript
async function getProfile(profileId) {
const { data } = await axios.get(`https://modheader.com/api/public/profile/${profileId}`, {
headers: {
authorization: `Bearer ${apiKey}`
}
});
}
PUT
/api/public/profile/{profileId}
(Update profile)
Update an exported ModHeader profile.
You can find the profile ID from the exported profile URL. The profile ID is the last part of your profile URL.
The profile
field is a JSON object that represents the new profile to use. The easiest way to obtain this profile
JSON object is to go to the exported profile page, look for the JSON format section, and click on Show JSON to see the JSON representation of the profile. Some interesting fields includes:
name type data type description title required string The profile title (shown at the top of ModHeader) shortTitle required string Single character text shown inside the round profile icon textColor required string Determines the profile foreground text color. backgroundColor required string Determines the profile background color version required number ModHeader profile version. Please use 2
headers optional array An array of request headers. Includes enabled
(boolean),name
(string), andvalue
(string)respHeaders optional array An array of response headers. Includes enabled
(boolean),name
(string), andvalue
(string)cookieHeaders optional array An array of cookies to use in the cookie request header. Includes enabled
(boolean),name
(string), andvalue
(string)setCookieHeaders optional array An array of cookies to use in the set-cookie response headers. Includes enabled
(boolean),name
(string), andvalue
(string)cspHeaders optional array An array of CSP directives to use. Includes enabled
(boolean),name
(string), andvalue
(string)urlReplacements optional array An array of URL replacements to use. Includes enabled
(boolean),name
(string, representing the original URL), andvalue
(string, representing the replacement string)tabFilters optional array An array of tab filters. Includes enabled
(boolean),tabId
(number)initiatorDomainFilters optional array An array of tab domain filters. Includes enabled
(boolean),domain
(string)urlFilters optional array An array of request URL filters. Includes enabled
(boolean),urlRegex
(string)excludeUrlFilters optional array An array of exclude request URL filters. Includes enabled
(boolean),urlRegex
(string)resourceFilters optional array An array of resource type filters. Includes enabled
(boolean),resourceType
(array of enums such asmain_frame
,sub_frame
,xmlhttprequest
,stylesheet
, etc.)
POST Body
name type data type description profile required object The new profile to update to
Responses
http code content-type response 200
application/json
{"success": true}
400
text/plain
The request is invalid. Please make sure that the POST body is correct. 401
text/plain
Invalid API key
Example Javascript
async function updateProfile(profileId) {
const { data } = await axios.put(
`https://modheader.com/api/public/profile/${profileId}`,
{
profile: {
title: 'Profile 1',
backgroundColor: '#2ea9af',
headers: [{ enabled: true, name: 'test', value: 'hello world' }],
shortTitle: '3',
textColor: '#ffffff',
version: 2
}
},
{
headers: {
authorization: `Bearer ${apiKey}`
}
}
);
}
DELETE
/api/public/profile/{profileId}
(Delete profile)
Delete the profile.
You can find the profile ID from the exported profile URL. The profile ID is the last part of your profile URL.
Responses
http code content-type response 200
application/json
{"success": true}
400
text/plain
The request is invalid. Please make sure that the POST body is correct. 401
text/plain
Invalid API key
Example Javascript
async function deleteProfile(profileId) {
const { data } = await axios.delete(`https://modheader.com/api/public/profile/${profileId}`, {
headers: {
authorization: `Bearer ${apiKey}`
}
});
}