An API wrapper for Stack Overflow for Teams
Project description
Stack Overflow for Teams API Wrapper
A Python wrapper for the Stack Overflow for Teams API, replicating the functionality of the Stack Overflow for Teams API in a more user-friendly way.
Full documentation for the API can be found at one of the following locations:
- Basic/Business API: https://api.stackoverflowteams.com/v3
- Enterprise API: https://YOUR.INSTANCE.URL/api/v3
Table of Contents
Setup
Install
Install the package using pip:
python3 -m pip install so4t_api
If you're running Windows, you'll probably need to use
py
instead ofpython3
API Authentication
To authenticate with the Stack Overflow API, you will need to generate a valid access token.
- For Basic or Business, instructions for creating a personal access token (PAT) can be found in this KB article.
- For Enterprise, follow the instructions in the KB article titled Secure API Token Generation Using OAuth with PKCE
NOTE: For Enterprise, if you'll be performing any API tasks that require posting or editing content (i.e. anything beyond just getting/reading content), you'll need to make sure to include the
write_access
scope when generating your token; otherwise, you will not be able to make the necessary updates to content via the API.
ANOTHER NOTE: For Enterprise, if you'll be using any of the impersonation methods, this will additionally require an API key, which will be submitted as an argument when instantiating StackClient. It will also require enabling impersonation, which involves sending a request to support@stackoverflow.com.
Usage
A basic example of how to use the wrapper in an application:
import os
from so4t_api import StackClient
# instantiate the StackClient
stack = StackClient(url=os.environ["SO_URL"], token=os.environ["SO_TOKEN"])
# get all questions
questions = stack.get_questions()
# Calculate total page views
total_views = 0
for question in questions:
total_views += question["viewCount"]
print(f"Total page views across {len(questions)} questions: {total_views}")
At this time, most/all the documentation for wrapper methods is documented along side the methods (i.e. in the code)
Support
Disclaimer: the creator of this project works at Stack Overflow, but it is a labor of love that comes with no formal support from Stack Overflow.
If you run into issues using the script, please open an issue. You are also welcome to edit the script to suit your needs, steal the code, or do whatever you want with it.
Project details
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
File details
Details for the file so4t_api-0.1.1.tar.gz
.
File metadata
- Download URL: so4t_api-0.1.1.tar.gz
- Upload date:
- Size: 31.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55f08b0e5772b5dc0876bb6a5fededb0985573e8aa5a7cfdcc6329287ac37735 |
|
MD5 | 831329baab00669687766a2eabef4f23 |
|
BLAKE2b-256 | 80e35caa963b2b9fd1aeac9b9c69bdb174689ccc12661554843231acab526e07 |
File details
Details for the file so4t_api-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: so4t_api-0.1.1-py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc3293eb0e53884a577a8b7060cb3f61903dbf7edefdaa8335eb3d9095ccba80 |
|
MD5 | 02f12beab4fd88873ea643e1c1c5c0b2 |
|
BLAKE2b-256 | 0c38d697e15d100f45bc2806adb2ba6f494516b40de043a167a4ed62e05d5207 |