Splunk Search

Python splunk-sdk vs Python requests library

DavidGuarneri
Path Finder

Is there any particular reason for using Python splunk-sdk over standard restful API libraries or tools (such as Python requests library)? Using standard Python, you should be able to import data into pandas with 3 lines:

 

response = requests.get(url)
data = response.json()
pd.DataFrame(data)

 

What does splunk-sdk have that Python requests does not?

 

Thanks!

0 Karma
1 Solution

livehybrid
SplunkTrust
SplunkTrust

Is your intention to query Splunk using some external python code, or are you building a Splunk add-on and using the inbuilt Splunk python?

You may gain some benefits from using the sdk if connecting to Splunk API from outside Splunk using the SDK, such as pagination, error catching, validation etc. It can also help abstract away from the particular API endpoints needed for interacting with the REST API and be maintained to reflect changes in Splunk through version updates to the SDK libraries.

Let me know if you have a particular use-case and we can see if there is a particular benefit/drawback to using the SDK and/or requests library.

Please let me know how you get on and consider accepting this answer or adding karma this answer if it has helped.
Regards

Will

View solution in original post

livehybrid
SplunkTrust
SplunkTrust

Is your intention to query Splunk using some external python code, or are you building a Splunk add-on and using the inbuilt Splunk python?

You may gain some benefits from using the sdk if connecting to Splunk API from outside Splunk using the SDK, such as pagination, error catching, validation etc. It can also help abstract away from the particular API endpoints needed for interacting with the REST API and be maintained to reflect changes in Splunk through version updates to the SDK libraries.

Let me know if you have a particular use-case and we can see if there is a particular benefit/drawback to using the SDK and/or requests library.

Please let me know how you get on and consider accepting this answer or adding karma this answer if it has helped.
Regards

Will

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...