# Why Does Jenkins REST API Return {} While Console Logs Show Build Output?

**URL:** <https://community.jenkins.io/t/why-does-jenkins-rest-api-return-while-console-logs-show-build-output/28004>\
**Category:** Ask a question\
**Tags:** question\
**Created:** [March 10, 2025, 6:10am UTC](https://community.jenkins.io/t/why-does-jenkins-rest-api-return-while-console-logs-show-build-output/28004 "2025-03-10T06:10:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![lakshmishreea122003](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/lakshmishreea122003/32/13569_2.png) [@lakshmishreea122003](https://community.jenkins.io/u/lakshmishreea122003)\
**Post date:** [March 10, 2025, 6:10am UTC](https://community.jenkins.io/t/why-does-jenkins-rest-api-return-while-console-logs-show-build-output/28004/1 "2025-03-10T06:10:18Z")

</div>

I am trying to fetch data from a Jenkins public instance ([ci.jenkins.io](http://ci.jenkins.io)) using the REST API.

When I use

```auto
import requests
url = "https://ci.jenkins.io/job/Websites/job/jenkins.io/job/master/lastBuild/api/json"
response = requests.get(url)
print(response.json())

```

It returns {}.

However, fetching logs works fine:

```auto
import requests
url = 'https://ci.jenkins.io/job/Websites/job/jenkins.io/job/master/lastBuild/consoleText'
response = requests.get(url)
print(response.text)

```

Why does the API return {} and not build details (like result, changeSets, duration)?  
Could someone share a Python code example that returns non-empty JSON data using the REST API?

---

<div class="post-metadata">

**Author:** ![mawinter69](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/mawinter69/32/1625_2.png) [@mawinter69](https://community.jenkins.io/u/mawinter69)\
**Post date:** [March 10, 2025, 9:46am UTC](https://community.jenkins.io/t/why-does-jenkins-rest-api-return-while-console-logs-show-build-output/28004/2 "2025-03-10T09:46:09Z")

</div>

When you try to fetch the data as XML you get redirected to [Redirects from ci.jenkins.io](https://www.jenkins.io/infra/ci-redirects/)  
So maybe it is intentional not to return that data

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [March 10, 2025, 1:22pm UTC](https://community.jenkins.io/t/why-does-jenkins-rest-api-return-while-console-logs-show-build-output/28004/3 "2025-03-10T13:22:37Z")

</div>

You’ll need to run your own instance of Jenkins to gather that type of data rather than gathering it from [ci.jenkins.io](http://ci.jenkins.io).

---

<div class="post-metadata">

**Author:** ![lakshmishreea122003](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/lakshmishreea122003/32/13569_2.png) [@lakshmishreea122003](https://community.jenkins.io/u/lakshmishreea122003)\
**Post date:** [March 10, 2025, 4:29pm UTC](https://community.jenkins.io/t/why-does-jenkins-rest-api-return-while-console-logs-show-build-output/28004/4 "2025-03-10T16:29:43Z")

</div>

@mawinter69 and @MarkEWaite Thanks for the info .  
I am aiming to contribute to the gsoc project [Domain-Specific LLM for Jenkins](https://www.jenkins.io/projects/gsoc/2025/project-ideas/domain-specific-LLM-based-on-jenkins-usage-using-ci.jenkins.io-data/) . For this project mentors specified to use Rest API to get [ci.jenkins.io](http://ci.jenkins.io) data and not to web scrape.  
Since Rest API is not providing the necessary info, Is it acceptable to use the `/consoleText` API endpoint for this project?  
Your input will be really valuable. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [March 10, 2025, 4:49pm UTC](https://community.jenkins.io/t/why-does-jenkins-rest-api-return-while-console-logs-show-build-output/28004/5 "2025-03-10T16:49:44Z")

</div>

> [@lakshmishreea122003](#):
>
> Is it acceptable to use the `/consoleText` API endpoint for this project?

I don’t think that will work. The Jenkins infra team has found that recent activity appears to be overloading [ci.jenkins.io](http://ci.jenkins.io) with requests. They are now considering safety measures that will prevent that type of overload from happening in the future. The overload looks suspiciously like a large language model that is pushing an enormous number of requests to [ci.jenkins.io](http://ci.jenkins.io), harming its ability to perform its primary mission, running continuous integration jobs for Jenkins contributors.

---

<div class="post-metadata">

**Author:** ![lakshmishreea122003](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/lakshmishreea122003/32/13569_2.png) [@lakshmishreea122003](https://community.jenkins.io/u/lakshmishreea122003)\
**Post date:** [March 10, 2025, 7:02pm UTC](https://community.jenkins.io/t/why-does-jenkins-rest-api-return-while-console-logs-show-build-output/28004/6 "2025-03-10T19:02:17Z")

</div>

@MarkEWaite Sir thanks for the info.  
But if web scraping and /consoleText API not acceptable and the Rest API not able to gather data from [ci.jenkins.io](http://ci.jenkins.io), then would there be any recommended way to collect data in a compliant manner that aligns with Jenkins Infra Team’s guidelines for this project [Domain-Specific LLM for Jenkins](https://www.jenkins.io/projects/gsoc/2025/project-ideas/domain-specific-LLM-based-on-jenkins-usage-using-ci.jenkins.io-data/).  
Any guidance you could provide would really help me prepare a stronger GSoC proposal and gain a better understanding of the project.  
Thank you sir

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [March 10, 2025, 7:18pm UTC](https://community.jenkins.io/t/why-does-jenkins-rest-api-return-while-console-logs-show-build-output/28004/7 "2025-03-10T19:18:47Z")

</div>

> [@lakshmishreea122003](#):
>
> would there be any recommended way to collect data in a compliant manner that aligns with Jenkins Infra Team’s guidelines for this project [Domain-Specific LLM for Jenkins](https://www.jenkins.io/projects/gsoc/2025/project-ideas/domain-specific-LLM-based-on-jenkins-usage-using-ci.jenkins.io-data/).

I think that you can install your own Jenkins controller locally, run jobs on that controller, and use the results from those jobs to test drive your locally large language model.

We might also be able to persuade the Jenkins infrastructure team to provide a compressed archive of console logs that could be used as an initial sample of data. I haven’t discussed it with them, but since the instance is publicly readable, I would expect that the build logs from the jobs could be saved in a compressed archive for download by anyone that wants to use them for experimentation.

---

<div class="post-metadata">

**Author:** ![lakshmishreea122003](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/lakshmishreea122003/32/13569_2.png) [@lakshmishreea122003](https://community.jenkins.io/u/lakshmishreea122003)\
**Post date:** [March 11, 2025, 1:47am UTC](https://community.jenkins.io/t/why-does-jenkins-rest-api-return-while-console-logs-show-build-output/28004/8 "2025-03-11T01:47:13Z")

</div>

@MarkEWaite  
Thanks for your response.
