Does GhostTrack Have a Public API? Understanding the CLI Architecture
GhostTrack does not expose a public REST API; it is a stand-alone Python command-line tool that performs IP, phone number, and username lookups locally while internally consuming third-party services like ipwho.is and api.ipify.org.
The HunxByts/GhostTrack repository is an open-source OSINT utility designed for interactive terminal usage rather than web service integration. While developers frequently search for a GhostTrack API to embed tracking capabilities into their applications, the tool's architecture centers on a text-based menu system defined in GhostTR.py. Understanding how to import its internal functions or wrap them in your own HTTP layer provides the programmatic access that a native API would offer.
Architectural Overview: Why GhostTrack Has No Built-in API
GhostTrack operates as a self-contained script without any HTTP server components or exposed endpoints. The main entry point in GhostTR.py presents an interactive menu that executes one of four operations locally on the machine.
Local CLI Design
When you run GhostTR.py, the script calls functions such as IP_Track(), TrackIP(), phoneGW(), and TrackPhone() directly within the Python process. These functions handle user input via the built-in input() function and print results to stdout. Because the logic is tightly coupled to the interactive prompt, the tool lacks the request/response cycle typical of a GhostTrack API service.
Third-Party API Consumption
While GhostTrack does not offer its own API, it leverages several external data sources:
ipwho.isfor IP geolocation and ISP detailsapi.ipify.orgfor retrieving the caller's public IP addressphonenumberslibrary for parsing and validating phone number metadata- Direct HTTP
GETrequests to social media platforms for username verification
These external services provide the data that GhostTrack formats and displays in the terminal.
How to Use GhostTrack Programmatically
Since no native GhostTrack API exists, you must import the script's functions directly into your Python code. This approach treats GhostTrack as a module rather than a service.
Importing the IP Tracker Function
The IP_Track() function in GhostTR.py queries ipwho.is for IP address intelligence. Because the original function calls input() interactively, you must patch the built-in input function to supply arguments programmatically:
# Example: programmatic use of GhostTrack's IP lookup
from GhostTR import IP_Track
# Monkey-patch `input` to supply the IP without interactive prompt
def mock_input(prompt):
return "8.8.8.8" # example IP address
# Replace built-in input temporarily
import builtins
original_input = builtins.input
builtins.input = mock_input
try:
IP_Track() # prints the IP information to stdout
finally:
builtins.input = original_input
This technique allows you to reuse the existing logic while bypassing the interactive CLI.
Importing the Phone Number Tracker
Similarly, the phoneGW() function wraps the phonenumbers library to display carrier, region, and timezone information. You can import and call this function by mocking the input mechanism:
from GhostTR import phoneGW
def mock_input(prompt):
return "+14155552671" # example US mobile number
import builtins
orig = builtins.input
builtins.input = mock_input
try:
phoneGW() # displays carrier, region, timezone, etc.
finally:
builtins.input = orig
Building Your Own GhostTrack API Wrapper
If your application requires HTTP endpoints, you can wrap GhostTrack's functions in a lightweight web framework like Flask or FastAPI. This creates your own GhostTrack API layer on top of the existing CLI tool.
Flask Integration Example
The following example exposes an /ipinfo endpoint that reuses the IP lookup logic. Note that for production use, you should refactor the functions to return data objects rather than printing to stdout:
from flask import Flask, request, jsonify
from GhostTR import IP_Track
app = Flask(__name__)
@app.route("/ipinfo")
def ipinfo():
ip = request.args.get("ip", "")
# Re-use the existing logic by calling the internal helper directly
# (You may refactor IP_Track to return data instead of printing)
# For illustration we just forward to the external service:
import requests, json
resp = requests.get(f"http://ipwho.is/{ip}")
return jsonify(json.loads(resp.text))
if __name__ == "__main__":
app.run(port=5000)
This pattern allows you to build RESTful interfaces around GhostTrack's core functionality while maintaining separation between the CLI tool and your web service.
Key Files and Functions
Understanding the repository structure helps clarify why the GhostTrack API must be built rather than discovered:
GhostTR.py: The core script containing all tracking logic, menu definitions, and third-party API calls. This file definesIP_Track(),phoneGW(), and other primary functions.requirements.txt: Lists dependencies includingrequestsandphonenumbersthat enable the tool to communicate with external data sources.README.md: Documents command-line usage only; contains no API reference or endpoint documentation.
Summary
- GhostTrack is a CLI utility, not a web service, and provides no native HTTP API according to the source code in
GhostTR.py. - Four tracking modules exist: IP lookup (via ipwho.is), public IP detection (via api.ipify.org), phone number analysis (via phonenumbers library), and username enumeration (via direct HTTP requests).
- Programmatic reuse is possible by importing functions like
IP_TrackandphoneGWfromGhostTR.py, though you must handle the interactiveinput()calls via mocking. - Custom API creation requires wrapping these functions in Flask, FastAPI, or similar frameworks, as the tool is designed for terminal interaction rather than server deployment.
Frequently Asked Questions
Does GhostTrack expose a REST API endpoint?
No. GhostTrack is built as an interactive command-line interface in GhostTR.py with no HTTP server components, routing, or JSON response handlers. It operates entirely within the Python process and prints results to the terminal.
Can I call GhostTrack functions from my own Python script?
Yes. You can import specific functions such as from GhostTR import IP_Track or from GhostTR import phoneGW. Since these functions rely on input() for arguments, you will need to temporarily monkey-patch builtins.input to pass parameters programmatically.
Which external APIs does GhostTrack use internally?
GhostTrack consumes ipwho.is for IP geolocation data, api.ipify.org to detect the user's public IP address, and the phonenumbers library (which does not use HTTP but parses local data) for telephone metadata. Username tracking performs direct HTTP GET requests to various social media platform URLs without using a centralized API service.
How do I convert GhostTrack into a web API?
You must create a wrapper using a Python web framework like Flask or FastAPI. Import the tracking functions from GhostTR.py and expose them via routes. For production deployments, refactor the functions to return dictionaries or objects instead of printing to stdout, then serialize those returns as JSON responses.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →