Is it possible to use the request crate inside of a solana program to make a GET request to an API, and parse it inside the program? Or any way to make an API call from inside a contract/program?
2 Answers
You can't make HTTP connections or other network connections in your on-chain application.
This is the purpose oracles serve. Oracles get data off-chain, then send instructions to the chain to put that data into accounts on-chain that programs can access. It sounds like you want to do something similar: make your GET request off-chain, run some instruction that puts that data in an account on chain, then you can access it.
You cannot make any IO requests from within a program.
This would break the deterministic nature of transactions where any validator could reproduce the transaction output at a later date.