GPT API
To access the GPT endpoint, send a POST request to: https://www.jblanked.com/news/api/gpt/
Include a "content" key with your query as the value.
If the POST request is successful, it returns a JSON object with a "task_id" key containing the Task ID, and a "message" key indicating 'Task started'.
To get the response, send a GET request to: https://www.jblanked.com/news/api/gpt/status/YOUR-TASK-ID, where "YOUR-TASK-ID" is the Task ID provided by the POST request.
{
"content": "In less than 8 words, what does bullish mean?"
}
{
"status": "complete",
"message": "Expecting rising prices or market growth."
}
GET Requests Usage
struct GPTResponsePost: Decodable {
var task_id: String
var message: String
}
let baseURL: String = "https://www.jblanked.com/news/api/gpt/mobile/"
var components = URLComponents(string: baseURL)
components?.queryItems = [
URLQueryItem(name: "message", value: "In less than 8 words, what does bullish mean?")
]
if let url = components?.url {
var request = URLRequest(url: url)
request.addValue("Api-Key YOUR-API-KEY", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
do {
let (dataReturned, _) = try await URLSession.shared.data(for: request)
let decoder = JSONDecoder()
let response = try decoder.decode(GPTResponsePost.self, from: dataReturned)
print(response.task_id)
} catch {
print("Error has occurred: \(error)")
}
}
url = "https://www.jblanked.com/news/api/gpt/"
headers = {
"Content-Type": "application/json",
"Authorization": "Api-Key YOUR-API-KEY"
}
data = {"content": "In less than 8 words, what does bullish mean?"}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
task_id = response.json()["task_id"]
print(task_id)
#include <jb-requests.mqh>
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
CRequests request;
request.url = "https://www.jblanked.com/news/gpt/";
request.key = "YOUR_API_KEY";
request.loader["content"] = "What does bullish mean?"
if(!request.POST())
{
Print("Failed to send GPT request");
return INIT_FAILED;
}
// print result
Print(request.result);
// or do something with the json data
string taskID = request.loader["task_id"].ToStr();
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
Library Usage
import JBNews
let yourAPIKey: String = "YOUR-API-KEY"
let newsModel = JBNews(yourAPIKey)
Task {
let messageResponse: String = await newsModel.gpt(message: "In less than 8 words, what does bullish mean?")
print(messageResponse)
}
from jb_news.news import CJBNews
jb = CJBNews()
api_key = "YOUR_API_KEY_HERE"
gpt_response = jb.GPT(api_key, "What does bullish mean in forex?")
print(gpt_response)
// MQL library usage is not available yet.
🤖 Ready to integrate AI-powered sentiment analysis into your trading app?
Get instant access to GPT-powered forex insights and predictions.