momentum.sh
  • 💡Introduction to Momentum
    • Overview
    • How can momentum help you?
    • Why is it open source
    • Contributing to momentum
    • Troubleshooting & Feedback
  • Getting Started
    • Hers's what you will need
    • Installation
      • Cloud Integrations (Optional)
        • Portkey
        • Firebase
        • Setting up Github App
        • Enabling Github Auth on Firebase
        • Google Cloud
    • Running Momentum
    • Known bugs & fixes
  • Using Momentum
    • Underlying API structure
    • Auth
    • Logging in
    • User Registration
    • Parsing codebase
    • Getting list of all parsed projects
    • Getting list of all branches in a project
    • Listing all endpoints of a branch
    • Understanding Changes & Impacts
    • Generating Blast Radius
    • Get Flow Graph
    • Get Dependencies
    • Get More Dependencies (AI)
    • Getting code of a specific node
    • Testing your code
    • Generating a test plan
    • Setting up the test plan
    • Preferences
      • Setting preferences of a specific endpoint
      • Getting preferences for specific endpoint
    • Generating tests
  • Using Momentum CLI
Powered by GitBook
On this page

Was this helpful?

  1. Using Momentum

Getting code of a specific node

GET /code/node

Get the code of a specific node in the parsed codebase. These nodes are typically your endpoints or their child functions that were listed as part of flow graph.

Headers

Name
Value

Authorization

Bearer <token>

Query Params

Name
Type
Description

project_id

number

The project id generated during parsing of the code

node_id

string

The node id that points to the specific node you want to get code of

Response

{
    "code": "@api.get(\"/search\")\ndef search(args):\n    q = args.get(\"q\", None)\n\n    if q is None:\n        return { \"error\": \"q parameter required\" }\n    else:\n        results = []\n        for item in example_data[\"items\"]:\n            if item[\"name\"].count(q) > 0:\n                results.append(item)\n        return { \"count\": len(results), \"items\": results }",
    "file": "local-file-path/filename.py",
    "project_id": 4,
    "response": "",
    "start": 55,
    "end": 66,
    "id": "/server.py:search",
    "type": "function",
    "parameters": "[{\"identifier\": \"args\", \"type\": null}]"
}
null //in case no node was found 
{
    "status_code": 400,
    "detail": "Project Details not found." //the project id is incorrect
}
PreviousGet More Dependencies (AI)NextTesting your code

Last updated 11 months ago

Was this helpful?