Splunk® Enterprise

Search Manual

Download manual as PDF

Splunk Enterprise version 6.x is no longer supported as of October 23, 2019. See the Splunk Software Support Policy for details. For information about upgrading to a supported version, see How to upgrade Splunk Enterprise.
Download topic as PDF

Export data using the Splunk REST API

Use the Splunk REST API to access data from the command line or a Web browser.

REST API access for Splunk Cloud deployments

If you have a self-service Splunk Cloud deployment and you want to use the Splunk REST API, file a Support ticket requesting the API to be enabled. See Using the REST API with Splunk Cloud in the REST API Tutorials for more details.

Export data

Exporting data starts with running a search job to generate results. You can then export this search result data to a file.

  1. Run a search job using a POST to /services/search/jobs/. If you are using a custom time range, pass it in with the POST request.
    curl -k -u admin:changeme \
         https://localhost:8089/services/search/jobs/ -d search="search sourcetype=access_* earliest=-7d"
  2. Get the search job ID (SID) for the search. The /jobs endpoint returns an XML response including the <sid>, or search job ID.
    <?xml version='1.0' encoding='UTF-8'?>

    You can also get the search job ID by viewing the job in the Search Job Inspector. in Splunk Web. Navigate to Activity > Jobs to open the Job Manager. Locate the search job that you just ran and click Inspect. The Search Job Inspector opens in a separate window. See View the properties of a search job.

  3. Use a GET request on the /results endpoint to export the search results to a file. Ensure that you do the following in the GET request:
    • Identify your object endpoints.
      To see a list of currently available object endpoints for your user, within your app, navigate to https://localhost:8089/servicesNS/<user>/<app>/.
      For example:
    • Identify the search job user and app.
      The following example defines <user> as admin and <app> as search.
    • Identify an output format.
      Use the output_mode parameter to specify one of the following available output formats. Use lower case for the format name, as shown here.
      atom | csv | json | json_cols | json_rows | raw | xml

      This example exports search results to a JSON file.

      curl -u admin:changeme \
           -k https://localhost:8089/servicesNS/admin/search/jobs/1423855196.339/results/ \
           --get -d output_mode=json -d count=5

See also

For more details about the /jobs and /export endpoints, see the following information in the REST API Reference.

See also Creating searches using the REST API in the REST API Tutorials.

Export data using the CLI
Export data using the Splunk SDKs

This documentation applies to the following versions of Splunk® Enterprise: 6.4.0, 6.4.1, 6.4.2, 6.4.3, 6.4.4, 6.4.5, 6.4.6, 6.4.7, 6.4.8, 6.4.9, 6.4.10, 6.4.11, 6.5.0, 6.5.1, 6.5.1612 (Splunk Cloud only), 6.5.2, 6.5.3, 6.5.4, 6.5.5, 6.5.6, 6.5.7, 6.5.8, 6.5.9, 6.5.10, 6.6.0, 6.6.1, 6.6.2, 6.6.3, 6.6.4, 6.6.5, 6.6.6, 6.6.7, 6.6.8, 6.6.9, 6.6.10, 6.6.11, 6.6.12, 7.0.0, 7.0.1, 7.0.2, 7.0.3, 7.0.4, 7.0.5, 7.0.6, 7.0.7, 7.0.8, 7.0.9, 7.0.10, 7.0.11, 7.0.13, 7.1.0, 7.1.1, 7.1.2, 7.1.3, 7.1.4, 7.1.5, 7.1.6, 7.1.7, 7.1.8, 7.1.9, 7.1.10, 7.2.0, 7.2.1, 7.2.2, 7.2.3, 7.2.4, 7.2.5, 7.2.6, 7.2.7, 7.2.8, 7.2.9, 7.3.0, 7.3.1, 7.3.2, 7.3.3, 7.3.4, 8.0.0, 8.0.1, 8.0.2


"This example exports search results to a JSON file" is incorrect. The curl command will spit the results out to stdout. One could easily capture it to a file, though, by adding the "--output <filename>" option to the curl command.

June 19, 2019

Thank you for this suggestion!

Lstewart splunk, Splunker
December 17, 2018

FYI, I have found the oneshot ( blocking search 1 call ) option and passing in your own SID both useful in simplifying the call sequence

December 14, 2018

I had to use


under my 7.1.1 system.

July 12, 2018

Hi @Emiller42,
I have reviewed and updated the instructions here to include the full list of output mode options. I have also verified that you can use lower case to specify output_mode= csv.
Thanks for bringing this to our attention!

Frobinson splunk, Splunker
February 14, 2017

Some of this is out of date. It lists valid output_mode values as `JSON`, `CSV`, or `XML` which is incorrect. According to current documentation on the `/results` endpoint, valid values are: `atom | csv | json | json_cols | json_rows | raw | xml`

Also, case matters. `csv` will return results, while `CSV` will produce an error.

February 9, 2017

Was this documentation topic helpful?

Enter your email address, and someone from the documentation team will respond to you:

Please provide your comments here. Ask a question or make a suggestion.

You must be logged into splunk.com in order to post comments. Log in now.

Please try to keep this discussion focused on the content covered in this documentation topic. If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk, consider posting a question to Splunkbase Answers.

0 out of 1000 Characters