Skip to main content

sn_restapi_wrapper

About

This package acts as a wrapper for ServiceNow RESTAPI application enabling a user to extract data from any table within ServiceNow within a particular time duration, ideally as a date-time format.

The package overcomes the standard limitation of the ServiceNow RESTAPI by using a function of offset, with a rate limit of 5000 and then iterating over the users given time duration. To speed the efficiency of the package threading is used to execute tasks concurrently within the same process for a given time duration- where the tasks are split by the date.

Installation

Install the package into your env using pip install sn-restapi-wrapper

Requirements

The core-package requires these applications to be present at minimum

  1. requests
  2. pandas
  3. concurrent.futures
  4. tqdm

Usage

Standard Query - Without filters

# ServiceNow credentials instance URL and endpoint
instance_url = 'https://xxx.service-now.com'  # Replace with specified url
endpoint = '/api/now/table/xxx'  # Replace with table name [incident, incident_task, ...]

# Replace 'username' and 'password' with ServiceNow credentials
username = 'xxx' 
password = 'xxx'

# Import the sn_restapi_wrapper as srw 
import sn_restapi_wrapper as srw

# Example usage:

# Specify a list of field names to extract
fields = []

# Important: specify fields names used in the backed system. If no fields are mentioned as a list all fields will be pulled but be more time consuming.

# Important: specify start/end date and  start/end time within specified format
start_date = 'yyyy-mm-dd'
end_date = 'yyyy-mm-dd'
start_time = 'HH:mi:ss'
end_time = 'HH:mi:ss'
date_field = 'xxx' # Ensure the date field is properly specified  e.g 'sys_created_on'

# Pulling data into a pandas dataframe
data = srw.fetch_filtered_data(
	instance_url, 
	endpoint, 
	date_field, 
	start_date, 
	end_date, 
	start_time, 
	end_time, 
	username, 
	password, 
	fields
)

# Examine data frame
data.shape

Custom Query - With filters

# ServiceNow credentials instance URL and endpoint
instance_url = 'https://xxx.service-now.com'  # Replace with specified url
endpoint = '/api/now/table/xxx'  # Replace with table name [incident, incident_task, ...]

# Replace 'username' and 'password' with ServiceNow credentials
username = 'xxx' 
password = 'xxx'

# Import the sn_restapi_wrapper as srw 
import sn_restapi_wrapper as srw

# Example usage:

# Specify a list of field names to extract
fields = []

# Important: specify fields names used in the backed system. If no fields are mentioned as a list all fields will be pulled but be more time consuming.

# Important: specify start/end date and  start/end time within specified format
start_date = 'yyyy-mm-dd'
end_date = 'yyyy-mm-dd'
start_time = 'HH:mi:ss'
end_time = 'HH:mi:ss'
date_field = 'xxx' # Ensure the date field is properly specified  e.g 'sys_created_on'
filter = 'xxxxxxx' # Ensure additional filter is specified

# Pulling data into a pandas dataframe fetch_filtered_data_custom for filtered data
data = srw.fetch_filtered_data_custom(
	instance_url, 
	endpoint, 
	date_field, 
	start_date, 
	end_date, 
	start_time, 
	end_time, 
	username, 
	password, 
	fields,
	additional_filter=filter
)

# Examine data frame
data.shape

License

This project is licensed under the MIT License. However, this doesnot include the ServiceNow RestAPI which is the sole property of ServiceNow. This is only a wrapper for the ServiceNow RestAPI.

Contact

For support, please contact mihinduperera35@gmail.com

Change Log

=============================

1.0.0 (2024-06-20)

  • First release for pre-release testing

1.0.1 (2024-06-20)

  • Second release for pre-release model with updated README.md with use case

1.0.2 (2024-06-20)

  • Third release for pre-release model with updated README.md with use case

1.0.3 (2024-06-20)

  • Fourth release for pre-release model with updated README.md with use case

1.0.4 (2024-06-20)

  • Fifth release for pre-release model with updated README.md with use case

1.1.0 (2024-07-01)

  • First release for standard (previous pre-release) and custom query application with updated README.md with use case

1.1.1 (2024-07-01)

  • First release for standard (previous pre-release) and custom query application (correction) with updated README.md with use case

1.1.2 (2024-07-01)

  • First release for standard (previous pre-release) and custom query application (correction) with updated README.md with use case

1.1.3 (2025-04-18)

  • First release for standard (previous pre-release) and custom query application (correction) with bug fix for SSL verification

1.1.4 (2025-04-18)

  • First release for standard (previous pre-release) and custom query application (correction) with bug fix for SSL verification and suppressed error notification

Metadata

Release files for sn-restapi-wrapper 1.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sn-restapi-wrapper 1.1.4
File Size Uploaded Provenance Actions
sn_restapi_wrapper-1.1.4.tar.gz 5.1 kB Without provenance Details for sn_restapi_wrapper-1.1.4.tar.gz

Release files / sn_restapi_wrapper-1.1.4.tar.gz

Download URL sn_restapi_wrapper-1.1.4.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
63d8a36b24a77aea9a34a3b6a4169cc0802729f7d965948df9f82f51885b526a
BLAKE2b-256 checksum
How to use checksums
cf30d0ceb75c74950fd7fcc38d438edfbacb28e466af00d94ddfa553489a3d06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.7

Security for sn-restapi-wrapper 1.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page