# Access results from an experiment without having to run the script again

I have ran an experiment in one of the IBM processors and the work has finished. However, I can not obtain the data as histograms or counts in the qiskit notebook because the experiment was concluded while I was logged off and therefore now I would need to run the full script again. That is, I would need to run the experiment again. My question is if there is some way to access the results in the notebook without this requirement. I know that the histograms are stored in the section "results" but I specifically want to work with them in the notebook. Thank you.

• If anyone is still wondering how to get the results of an old job, check out this video: youtube.com/watch?v=09-Qsge_qqo Mar 16 at 5:44

You can get a previous result by grabbing the corresponding job from the backend you sent it to:

from qiskit import *

backend = provider.get_backend('ibmq_BLAH')

#if you know the job ID
job = backend.retrieve_job('JOB_ID')

# if not, get the last 10 jobs on backend
jobs = backend.jobs()

• I found backend.jobs()[0].job_id() even more useful
– Max
May 16, 2020 at 3:47
• Is it possible to retrieve results from backends that have been retired? (so can't create a backend object for them) Jun 18, 2021 at 15:37
• provider.backend.jobs(backend_name=XXX) Jun 18, 2021 at 15:41

provider = IBMQ.load_account()


From this you can access a list of all your jobs with

provider.circuits.client.get_status_jobs()


Each job is recorded as a dictionary. One of the keys is 'id', which is the job id. To extract this for the first job on the list, for example, use

job_id = provider.circuits.client.get_status_jobs()[0]['id']


You can then use

job_info = provider.circuits.client.get_job(job_id)


To get a JSON which contains all the information about the job, including the results. The counts data for the first circuit in the job, for example, can be found at

job_info['qObjectResult']['results'][0]['data']['counts']


Though note that the strings will be hex strings rather than bit strings, and so will need conversion.

• Hi James, thank you for the answer. I followed your instructions and at the end I get some information about the execution of the job. However, I still don't know how to access the results from the notebook. When I introduce something like job.get_counts("some circuit") it tells me that "job" is not defined, so it seems that anyway I would have to execute the job again because for what I know this is the only way I can define it. Aug 29, 2019 at 13:38
• @Henao I added a line on how to get counts info. Aug 29, 2019 at 16:35
• Thanks James, I added the line but then it tells me that "job_info" is not defined. I changed it by job_id, since this is how the circuit was previously identified, and then it tells me that "string indices must be integers". I really don't understand the meaning or function of job_info and 'qObjectResult' in the command, although the other part of it is more intuitive. Sep 1, 2019 at 8:03
• Looks like I forgot to define job_info. See my new snippets Sep 2, 2019 at 11:05

When I tried getting data after using job = backend.retrieve_job('JOB_ID'), I got "QiskitError: 'Data for experiment "circuit0" could not be found.'"

When I tried using job_info = provider.circuits.client.get_job(job_id), I got "AttributeError: 'AccountProvider' object has no attribute 'circuits'."

What worked for me was job_info={the entire text of the json file downloaded from Results}, and then proceeding as James described above.

• Hey! What did you used as the JOBID? It sound like maybe this was incorrect. You can get the JobIDs of previously completed jobs by looking in the IBMQ Experience website Apr 16, 2020 at 22:10
• I used JobID 5e98731a4ff153001919fef9, on backend ibmq_ourense. Apr 18, 2020 at 19:03
• I think the API has changed, what Paul said in the second answer seemed to work for me, hope that helps! Apr 21, 2020 at 12:05