News API Documentation

Last Updated: 07/13/2024 21:07 EST

Welcome to our Forex News API, designed to equip traders and developers with comprehensive historical data, calendar information, and advanced AI-driven insights. Harness the power of OpenAI and machine learning to access detailed analyses of forex news events and related speeches, optimized for various programming languages including MQL5, MQL4, Swift, and Python.

Library Access

You can also access the API using GET requests. To authenticate your GET requests, include your API key in the header of your request. You can generate an API key in your profile.

Example Header:

{
  "Content-Type": "application/json",
  "Authorization": "Api-Key YOUR_API_KEY"
}
var request = URLRequest(url: URL(string: "https://www.jblanked.com/news/api/YOUR-END-POINT"))
request.addValue("Api-Key YOUR_API_KEY", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
string headers = "Content-Type: application/json" + "\r\n" + "Authorization: Api-Key YOUR_API_KEY";


API Description
Backtesting Machine Learning, Auto Smart analysis, and more.
Calendar List of events ordered by time
GPT Sentiment analysis on news events and statements



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": "What is the sentiment on the latest CPI report?"
}

{
  "status": "complete",
  "message": "The latest CPI report indicates a bearish sentiment."
}


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.