Python 3 Library to interact with and manage a ServiceNow instance via JSONv2
Project description
███████╗███╗ ██╗ ██████╗ ██╗ ██╗██████╗ ██╗ ██╗██████╗
██╔════╝████╗ ██║██╔═══██╗██║ ██║██╔══██╗╚██╗ ██╔╝╚════██╗
███████╗██╔██╗ ██║██║ ██║██║ █╗ ██║██████╔╝ ╚████╔╝ █████╔╝
╚════██║██║╚██╗██║██║ ██║██║███╗██║██╔═══╝ ╚██╔╝ ╚═══██╗
███████║██║ ╚████║╚██████╔╝╚███╔███╔╝██║ ██║ ██████╔╝
╚══════╝╚═╝ ╚═══╝ ╚═════╝ ╚══╝╚══╝ ╚═╝ ╚═╝ ╚═════╝
Python 3 Library for ServiceNow JSONv2 Rest API
*---------------------------------------------------------[ NOTE ]-*
* Based on servicenow 2.1.0 <https://pypi.org/project/servicenow/> *
* Wrttien by Francisco Freire <francisco.freire@locaweb.com.br> *
*------------------------------------------------------------------*
Installing
pip install snowpy3
Current version of SNOWPY3 works with NOW (Yokohama version)
Dependencies
- python-requests
- python-redis
NOTES
Works with the latest version of SNOW (Sep 13, 2025 checks)
SNOWPY3 Documentation
Overview
SNOWPY3 is a Python 3 library designed to interact with ServiceNow instances via the JSONv2 REST API. It provides an ORM-like interface for common ServiceNow operations with built-in caching capabilities.
Features
- 🔐 Authentication: Secure credential-based authentication
- 🚀 CRUD Operations: Complete Create, Read, Update, Delete functionality
- 📊 Caching: Redis-based caching with TTL support
- 🏗️ ORM Pattern: Object-oriented approach to ServiceNow tables
- 🔧 Flexible Queries: Support for both meta-based and query string operations
- 📋 Pre-built Tables: Ready-to-use classes for common ServiceNow tables
Quick Start
Basic Authentication
from snowpy3 import Auth
# Initialize connection
auth = Auth(
username='your_username',
password='your_password',
instance='your_instance', # or full URL like 'https://yourinstance.service-now.com'
timeout=120,
debug=False,
api='JSONv2'
)
Working with Incidents
from snowpy3 import SNOWPY3
from snowpy3 import Auth
# Create connection
auth = Auth('username', 'password', 'instance')
# Initialize Incident table handler
incident = SNOWPY3.Incident(auth)
# Create a new incident
new_incident = incident.create({
'short_description': 'Server Down',
'description': 'Production server is not responding',
'priority': '1',
'category': 'Hardware'
})
# List incidents
incidents = incident.list({'state': '1'}) # Active incidents
# Fetch specific incident
incident_data = incident.fetch_one({'number': 'INC0010001'})
# Update incident
incident.update(
where={'number': 'INC0010001'},
data={'state': '2', 'close_notes': 'Issue resolved'}
)
Available Table Classes
SNOWPY3 provides pre-built classes for common ServiceNow tables:
| Class | Table | Description |
|---|---|---|
Incident |
incident.do |
IT Service Management incidents |
Change |
change_request.do |
Change management requests |
Problem |
problem.do |
Problem management records |
User |
sys_user.do |
System users |
Group |
sys_user_group.do |
User groups |
ConfigurationItem |
cmdb_ci.do |
Configuration items |
Server |
cmdb_ci_server.do |
Server configuration items |
Router |
cmdb_ci_ip_router.do |
Router configuration items |
Switch |
cmdb_ci_ip_switch.do |
Switch configuration items |
Customer |
core_company.do |
Company records |
Journal |
sys_journal_field.do |
Journal entries |
Task |
task_ci_list.do |
Task lists |
Cluster |
cmdb_ci_cluster.do |
Cluster configuration items |
VPN |
cmdb_ci_vpn.do |
VPN configuration items |
Racks |
cmdb_ci_rack.do |
Rack configuration items |
Advanced Usage
Custom Queries
# Using query strings
incidents = incident.fetch_all_by_query("state=1^priority=1")
# Using meta parameters
incidents = incident.fetch_all({'state': '1', 'priority': '1'})
Time-based Queries
# Get incidents updated in the last 30 minutes
recent_incidents = incident.last_updated(30)
Batch Operations
# Create multiple incidents
incident_data = [
{'short_description': 'Issue 1', 'priority': '1'},
{'short_description': 'Issue 2', 'priority': '2'}
]
result = incident.create_multiple(incident_data)
# Delete multiple records
incident.delete_multiple("state=6") # Delete all closed incidents
Caching Configuration
from snowpy3 import Utils
# Enable caching (default is disabled)
Utils.ttl_cache = 300 # 5 minutes
# The caching is automatically applied to:
# - list()
# - list_by_query()
# - fetch_all()
# - fetch_all_by_query()
Configuration Options
Auth Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
username |
str | Required | ServiceNow username |
password |
str | Required | ServiceNow password |
instance |
str | Required | Instance name or full URL |
timeout |
int | 120 | Request timeout in seconds |
debug |
bool | False | Enable debug mode |
api |
str | 'JSONv2' | API version to use |
proxies |
dict | {} | HTTP proxies configuration |
verify |
bool | True | SSL certificate verification |
Redis Configuration
SNOWPY3 uses Redis for caching. Make sure Redis is running and accessible:
# Install and start Redis
sudo apt-get install redis-server
sudo systemctl start redis
Error Handling
try:
incidents = incident.fetch_all({'invalid_field': 'value'})
except Exception as e:
print(f"Error occurred: {e}")
Best Practices
- Security: Store credentials securely using environment variables or configuration files
- Caching: Enable caching for frequently accessed data
- Error Handling: Always implement proper error handling
- Rate Limiting: Be mindful of ServiceNow API rate limits
- Connection Pooling: Reuse Auth instances when possible
Troubleshooting
Common Issues
- Authentication Failed: Verify username/password and instance URL
- Timeout Errors: Increase timeout value for large queries
- Redis Connection: Ensure Redis server is running
- SSL Errors: Set
verify=Falsefor self-signed certificates (not recommended for production)
Debug Mode
Enable debug mode for detailed logging:
auth = Auth('username', 'password', 'instance', debug=True)
Contributing
Contributions are welcome! Please ensure:
- Code follows PEP 8 standards
- Add appropriate error handling
- Include docstrings for new methods
- Update tests for new functionality
License
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
Changelog
Version 2025.09.12.002
- Comprehensive testing framework with real ServiceNow instance validation
- Production readiness verification completed
- Enhanced error handling and type hints
- Complete test suite with 100% functionality coverage
Version 2025.09.12.001
- Initial release with Python 3.12 support
- Redis-based caching implementation
- Comprehensive ServiceNow table support
- JSONv2 API integration
Support
For support and questions:
- 📧 Email: snowpy3@tangonine.com
- 🌐 Website: https://www.tangonine.com
- 📚 Documentation: https://github.com/tango9/snowpy3/wiki
- 🐛 Issues: https://github.com/tango9/snowpy3/issues
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file snowpy3-2025.9.12.2.tar.gz.
File metadata
- Download URL: snowpy3-2025.9.12.2.tar.gz
- Upload date:
- Size: 61.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c4ab7e208163948037af08fc3261a5e7d04f001ba5a55537e8a7ebbb1273602
|
|
| MD5 |
59b495768790cfa7be82436f8b7d0791
|
|
| BLAKE2b-256 |
04051cd377db747512e147ff1292b9d4ecb1c6b52a3c748d2680258f211e4898
|
File details
Details for the file snowpy3-2025.9.12.2-py3-none-any.whl.
File metadata
- Download URL: snowpy3-2025.9.12.2-py3-none-any.whl
- Upload date:
- Size: 19.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c1860218e013028ce61c341be2b2268841f36111aff431bff79fa70b113414f
|
|
| MD5 |
7fc87aff758b756d44f323a9f1e31bf4
|
|
| BLAKE2b-256 |
e80477774ff4505bead3536b02a3eda45c9cc2863df32829c9dd17d82704696a
|