Credit Ratings

Country credit ratings, also known as sovereign credit ratings, are assessments of the creditworthiness or credit risk of a country’s government. These ratings are assigned by credit rating agencies, such as Standard & Poor’s (S&P) and Moody’s.

Latest

Using Requests:

import requests
api_key = 'YOUR_API_KEY'
url = f'https://api.tradingeconomics.com/credit-ratings?c={api_key}'
data = requests.get(url).json()
print(data)

Or using our package:

import tradingeconomics as te
te.login('your_api_key')
te.getCreditRatings()

Using Requests:

const axios = require("axios");
(async () => {
  const api_key = "YOUR_API_KEY";
  const response = await axios.get(
    `https://api.tradingeconomics.com/credit-ratings?c=${api_key}`
  );
  console.log(response.data);
})();

Or using our package:

const te = require("tradingeconomics");
te.login("your_api_key");
data = te.getCreditRatings().then(function (data) {
  console.log(data);
});

Using Requests:

using (var httpClient = new HttpClient())
{
    using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/credit-ratings?c=your_api_key"))
    {
        request.Headers.TryAddWithoutValidation("Upgrade-Insecure-Requests", "1");
        var response = await httpClient.SendAsync(request);
        if (response.IsSuccessStatusCode)
        {
            var content = await response.Content.ReadAsStringAsync();
            Console.WriteLine(content);
        }
    }
}

The response data format can be configured by appending the &f= parameter to the URL request.

/credit-ratings

CountryDateAgencyRatingOutlook
Kazakhstan10/27/2023Moody’sBaa2Positive
Isle of Man10/27/2023Moody’sAa3Stable
Costa Rica10/27/2023S&PBB-Stable

/credit-ratings?f=json

[{"Country":"Kazakhstan","Date":"10/27/2023","Agency":"Moody's","Rating":"Baa2","Outlook":"Positive"},{"Country":"Isle of Man","Date":"10/27/2023","Agency":"Moody's","Rating":"Aa3","Outlook":"Stable"},{"Country":"Costa Rica","Date":"10/27/2023","Agency":"S&P","Rating":"BB-","Outlook":"Stable"}]

/credit-ratings?f=csv

Country,Date,Agency,Rating,Outlook
Kazakhstan,10/27/2023,Moody's,Baa2,Positive
Isle of Man,10/27/2023,Moody's,Aa3,Stable
Costa Rica,10/27/2023,S&P,BB-,Stable

/credit-ratings?f=xml

<ArrayOfRatingsData xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/API.Models">
<RatingsHistoricalData>
<Agency>Moody's</Agency>
<Country>Kazakhstan</Country>
<Date>10/27/2023</Date>
<Outlook>Positive</Outlook>
<Rating>Baa2</Rating>
</RatingsHistoricalData>
<RatingsHistoricalData>
<Agency>Moody's</Agency>
<Country>Isle of Man</Country>
<Date>10/27/2023</Date>
<Outlook>Stable</Outlook>
<Rating>Aa3</Rating>
</RatingsHistoricalData>
<RatingsHistoricalData>
<Agency>S&P</Agency>
<Country>Costa Rica</Country>
<Date>10/27/2023</Date>
<Outlook>Stable</Outlook>
<Rating>BB-</Rating>
</RatingsHistoricalData>
</ArrayOfRatingsData>

Latest updates

Using Requests:

import requests
api_key = 'YOUR_API_KEY'
url = f'https://api.tradingeconomics.com/credit-ratings/updates?c={api_key}'
data = requests.get(url).json()
print(data)

Or using our package:

import tradingeconomics as te
te.login('your_api_key')
te.getCreditRatingsUpdates()

Using Requests:

const axios = require("axios");

(async () => {
  const api_key = "YOUR_API_KEY";
  const response = await axios.get(
    `https://api.tradingeconomics.com/credit-ratings/updates?c=${api_key}`
  );
  console.log(response.data);
})();

Or using our package:

const te = require("tradingeconomics");
te.login("your_api_key");

data = te.getCreditRatingsUpdates().then(function (data) {
  console.log(data);
});

Using Requests:

using (var httpClient = new HttpClient())
{
    using (var request = new HttpRequestMessage(
        HttpMethod.Get,
        "https://api.tradingeconomics.com/credit-ratings/updates?c=your_api_key"))
    {
        var response = await httpClient.SendAsync(request);
        if (response.IsSuccessStatusCode)
        {
            var content = await response.Content.ReadAsStringAsync();
            Console.WriteLine(content);
        }
    }
}

/credit-ratings/updates

CountryDateAgencyRatingOutlook
Mexico7/8/2022Moody’sBaa2Stable
Sweden4/17/2012DBRSAAAStable
Costa Rica10/27/2023S&PBB-Stable

/credit-ratings/updates?f=json

[{"Country":"Mexico","Date":"7/8/2022","Agency":"Moody's","Rating":"Baa2","Outlook":"Stable"},
 {"Country":"Sweden","Date":"4/17/2012","Agency":"DBRS","Rating":"AAA","Outlook":"Stable"}]

/credit-ratings/updates?f=csv

Country,Date,Agency,Rating,Outlook
Mexico,7/8/2022,Moody's,Baa2,Stable
Sweden,4/17/2012,DBRS,AAA,Stable

/credit-ratings/updates?f=xml

<ArrayOfRatingsData xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/API.Models">
  <RatingsHistoricalData>
    <Agency>Moody's</Agency>
    <Country>Mexico</Country>
    <Date>7/8/2022</Date>
    <Outlook>Stable</Outlook>
    <Rating>Baa2</Rating>
  </RatingsHistoricalData>
  <RatingsHistoricalData>
    <Agency>DBRS</Agency>
    <Country>Sweden</Country>
    <Date>4/17/2012</Date>
    <Outlook>Stable</Outlook>
    <Rating>AAA</Rating>
  </RatingsHistoricalData>
</ArrayOfRatingsData>

By country

Using Requests:

import requests
api_key = 'YOUR_API_KEY'
url = f'https://api.tradingeconomics.com/credit-ratings/country/sweden?c={api_key}'
data = requests.get(url).json()
print(data)

Or using our package:

te.getCreditRatings(country= 'sweden')

With multi countries

te.getCreditRatings(country=['mexico','sweden'])

Using Requests:

const axios = require("axios");
(async () => {
  const api_key = "YOUR_API_KEY";
  const response = await axios.get(
    `https://api.tradingeconomics.com/credit-ratings/country/sweden?c=${api_key}`
  );
  console.log(response.data);
})();

Or using our package:

data = te.getCreditRatings((country = "sweden")).then(function (data) {
  console.log(data);
});

With multi countries

data = te
  .getCreditRatings((country = ["mexico", "sweden"]))
  .then(function (data) {
    console.log(data);
  });

Using Requests:

new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/credit-ratings/country/sweden?c=your_api_key");

With multi countries

new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/credit-ratings/country/mexico,sweden?c=your_api_key");

/credit-ratings/country/{country}

CountryDateAgencyRatingOutlook
Sweden4/17/2012DBRSAAAStable
Sweden2/16/2004S&PAAAStable
Sweden4/4/2002Moody’sAaaStable

/credit-ratings/country/{country}?f=json

[{"Country":"Sweden","Date":"4/17/2012","Agency":"DBRS","Rating":"AAA","Outlook":"Stable"},{"Country":"Sweden","Date":"2/16/2004","Agency":"S&P","Rating":"AAA","Outlook":"Stable"},{"Country":"Sweden","Date":"4/4/2002","Agency":"Moody's","Rating":"Aaa","Outlook":"Stable"}]

/credit-ratings/country/{country}?f=csv

Country,Date,Agency,Rating,Outlook
Sweden,4/17/2012,DBRS,AAA,Stable
Sweden,2/16/2004,S&P,AAA,Stable
Sweden,4/4/2002,Moody's,Aaa,Stable

/credit-ratings/country/{country}?f=xml

<ArrayOfRatingsHistoricalData xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/API.Models">
<RatingsHistoricalData>
<Agency>DBRS</Agency>
<Country>Sweden</Country>
<Date>4/17/2012</Date>
<Outlook>Stable</Outlook>
<Rating>AAA</Rating>
</RatingsHistoricalData>
<RatingsHistoricalData>
<Agency>S&P</Agency>
<Country>Sweden</Country>
<Date>2/16/2004</Date>
<Outlook>Stable</Outlook>
<Rating>AAA</Rating>
</RatingsHistoricalData>
<RatingsHistoricalData>
<Agency>Moody's</Agency>
<Country>Sweden</Country>
<Date>4/4/2002</Date>
<Outlook>Stable</Outlook>
<Rating>Aaa</Rating>
</RatingsHistoricalData>
</ArrayOfRatingsHistoricalData>

Historical

Using Requests:

import requests
api_key = 'YOUR_API_KEY'
url = f'https://api.tradingeconomics.com/credit-ratings/historical?d1=2022-01-01&d2=2023-01-01&c={api_key}'
data = requests.get(url).json()
print(data)

Or using our package:

te.getHistoricalCreditRatings(initDate='2022-01-01',
 endDate='2023-01-01')

Using Requests:

const axios = require("axios");
(async () => {
  const api_key = "YOUR_API_KEY";
  const response = await axios.get(
    `https://api.tradingeconomics.com/credit-ratings/historical?d1=2022-01-01&d2=2023-01-01&c=${api_key}`
  );
  console.log(response.data);
})();

Or using our package:

data = te
  .getHistoricalCreditRatings(
    (start_date = "2022-01-01"),
    (end_date = "2023-01-01")
  )
  .then(function (data) {
    console.log(data);
  });

Using Requests:

new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/credit-ratings/historical?d1=2022-01-01&d2=2023-01-01&c=your_api_key");

/credit-ratings/historical?d1={yyyy-mm-dd}/d2={yyyy-mm-dd}

CountryDateAgencyRatingOutlook
Mexico7/8/2022Moody’sBaa2Stable
Mexico7/6/2022S&PBBBStable
Sweden4/17/2012DBRSAAAStable

/credit-ratings/historical?d1={yyyy-mm-dd}/d2={yyyy-mm-dd}&f=json

[{"Country":"Mexico","Date":"7/8/2022","Agency":"Moody's","Rating":"Baa2","Outlook":"Stable"},{"Country":"Mexico","Date":"7/6/2022","Agency":"S&P","Rating":"BBB","Outlook":"Stable"},{"Country":"Mexico","Date":"5/6/2021","Agency":"DBRS","Rating":"BBB","Outlook":"Stable"},{"Country":"Mexico","Date":"5/6/2020","Agency":"DBRS","Rating":"BBB","Outlook":"Negative"},
{"Country":"Sweden","Date":"3/8/2004","Agency":"Fitch","Rating":"AAA","Outlook":"Stable"},{"Country":"Sweden","Date":"2/16/2004","Agency":"S&P","Rating":"AAA","Outlook":"Stable"}]

/credit-ratings/historical?d1={yyyy-mm-dd}/d2={yyyy-mm-dd}&f=csv

Country,Date,Agency,Rating,Outlook
Mexico,7/8/2022,Moody's,Baa2,Stable
Mexico,7/6/2022,S&P,BBB,Stable
Mexico,5/6/2021,DBRS,BBB,Stable

/credit-ratings/historical?d1={yyyy-mm-dd}/d2={yyyy-mm-dd}&f=xml

<ArrayOfRatingsHistoricalData xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/API.Models">
<RatingsHistoricalData>
<Agency>Moody's</Agency>
<Country>Mexico</Country>
<Date>7/8/2022</Date>
<Outlook>Stable</Outlook>
<Rating>Baa2</Rating>
</RatingsHistoricalData>
<RatingsHistoricalData>
<Agency>S&P</Agency>
<Country>Mexico</Country>
<Date>7/6/2022</Date>
<Outlook>Stable</Outlook>
<Rating>BBB</Rating>
</RatingsHistoricalData>
<RatingsHistoricalData>
<Agency>DBRS</Agency>
<Country>Mexico</Country>
<Date>5/6/2021</Date>
<Outlook>Stable</Outlook>
<Rating>BBB</Rating>
</RatingsHistoricalData>
</ArrayOfRatingsHistoricalData>

Historical by country and date

Using Requests:

import requests
api_key = 'YOUR_API_KEY'
url = f'https://api.tradingeconomics.com/credit-ratings/historical/country/sweden?d1=2000-01-01&d2=2023-01-01?c={api_key}'
data = requests.get(url).json()
print(data)

Or using our package:

te.getHistoricalCreditRatings(country='sweden', initDate='2000-01-01',
 endDate='2023-01-01')

Using Requests:

const axios = require("axios");
(async () => {
  const api_key = "YOUR_API_KEY";
  const response = await axios.get(
    `https://api.tradingeconomics.com/credit-ratings/historical/country/sweden?d1=2000-01-01&d2=2023-01-01?c=${api_key}`
  );
  console.log(response.data);
})();

Or using our package:

data = te
  .getHistoricalCreditRatings(
    (historical = "sweden"),
    (start_date = "2023-01-01"),
    (end_date = "2000-01-01")
  )
  .then(function (data) {
    console.log(data);
  });

Using Requests:

new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/credit-ratings/historical/country/sweden?d1=2000-01-01&d2=2023-01-01?c=your_api_key");

/credit-ratings/historical/country/{country}/d1={yyyy-mm-dd}/d2={yyyy-mm-dd}

CountryDateAgencyRatingOutlook
Sweden4/17/2012DBRSAAAStable
Sweden2/16/2004S&PAAAStable
Sweden4/4/2002Moody’sAaaStable

/credit-ratings/historical/country/{country}/d1={yyyy-mm-dd}/d2={yyyy-mm-dd}?f=json

[{"Country":"Sweden","Date":"4/17/2012","Agency":"DBRS","Rating":"AAA","Outlook":"Stable"},{"Country":"Sweden","Date":"2/16/2004","Agency":"S&P","Rating":"AAA","Outlook":"Stable"},{"Country":"Sweden","Date":"4/4/2002","Agency":"Moody's","Rating":"Aaa","Outlook":"Stable"},{"Country":"Sweden","Date":"7/24/2000","Agency":"S&P","Rating":"AA+","Outlook":"Positive"}]

/credit-ratings/historical/country/{country}/d1={yyyy-mm-dd}/d2={yyyy-mm-dd}?f=csv

Country,Date,Agency,Rating,Outlook
Sweden,4/17/2012,DBRS,AAA,Stable
Sweden,2/16/2004,S&P,AAA,Stable
Sweden,4/4/2002,Moody's,Aaa,Stable

/credit-ratings/historical/country/{country}/d1={yyyy-mm-dd}/d2={yyyy-mm-dd}?f=xml

<ArrayOfRatingsHistoricalData xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/API.Models">
<RatingsHistoricalData>
<Agency>DBRS</Agency>
<Country>Sweden</Country>
<Date>4/17/2012</Date>
<Outlook>Stable</Outlook>
<Rating>AAA</Rating>
</RatingsHistoricalData>
<RatingsHistoricalData>
<Agency>S&P</Agency>
<Country>Sweden</Country>
<Date>2/16/2004</Date>
<Outlook>Stable</Outlook>
<Rating>AAA</Rating>
</RatingsHistoricalData>
<RatingsHistoricalData>
<Agency>Moody's</Agency>
<Country>Sweden</Country>
<Date>4/4/2002</Date>
<Outlook>Stable</Outlook>
<Rating>Aaa</Rating>
</RatingsHistoricalData>
</ArrayOfRatingsHistoricalData>

Response fields

FieldTypeDescriptionExample
CountrystringName of the country associated with the indicator.“Mexico”
DatestringRelease date and time of the data in UTC.“12/19/2013”
AgencystringName of the credit rating agency that issued the rating.“S&P”
RatingstringCredit rating assigned by the agency, reflecting creditworthiness.“BBB+”
OutlookstringAgency’s forward-looking expectation on the rating“Stable”