Create API Keys By Username
Introduction
The "Get API Key By Username" feature allows users to retrieve API keys associated with a specific username. This documentation provides details on how to retrieve API keys by username and includes code examples in various programming languages.
Retrieving API Key
To retrieve an API key by username, users need to make an HTTP GET request to the specified endpoint with the required parameters.
Endpoint
https://api.mypayd.app/v1/api_keys/CqHGA4HT3Nd4u5MmRFQW
Headers
The request should include an X-Auth-Token header with a valid token.
X-Auth-Token token
The Token object
The query parameters should include the username for which the API key is being retrieved.
{
"name": "user"
}
Code Examples
Below are code examples in different programming languages demonstrating how to retrieve API keys by username using an HTTP GET request.
- Curl
- Go
- Nodejs
- Python
- PHP
curl --location -g --request GET 'https://api.mypayd.app/v1/api_keys/CqHGA4HT3Nd4u5MmRFQW' \
--header 'X-Auth-Token: token' \
--data '{
"name": "user"
}'
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.mypayd.app/v1/api_keys/CqHGA4HT3Nd4u5MmRFQW"
method := "GET"
payload := strings.NewReader(`{
"name": "user"
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("X-Auth-Token", "token")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
var axios = require('axios');
var data = '{\n "name": "user"\n}';
var config = {
method: 'get',
maxBodyLength: Infinity,
url: 'https://api.mypayd.app/v1/api_keys/CqHGA4HT3Nd4u5MmRFQW',
headers: {
'X-Auth-Token': 'token'
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
url = "https://api.mypayd.app/v1/api_keys/CqHGA4HT3Nd4u5MmRFQW"
payload = "{\n \"name\": \"user\"\n}"
headers = {
'X-Auth-Token': 'token'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://api.mypayd.app/v1/api_keys/CqHGA4HT3Nd4u5MmRFQW');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'X-Auth-Token' => 'token'
));
$request->setBody('{\n "name": "user"\n}');
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
Conclusion
The "Get API Key By Username" feature provides a convenient way for users to retrieve API keys associated with specific usernames. By following the instructions outlined in this documentation, users can easily retrieve API keys and integrate them into their applications or services.