user11543: I have Stockfish compiled on my machine. Instead of just running the Stockfish program in the terminal, is it possible to interact with it in a separate program?
For example, some basic things I might want to do:

Create a position object from a FEN.    
Get an evaluation from the position object (limiting with depth or time).    
Return an array of positions for all the legal moves from the position.

These are just some very basic examples. Can anyone supply some code snippets for these instructions? I'm really struggling to find any helpful documentation.
EDIT: It looks like this really has a two part solution. The first is piping the input/output to some external program. The second is understanding the UCI protocol to perform what I want to do. Does anyone know the UCI protocol for getting all of the possible moves/positions from a given position? Also, it looks like the 'eval' command only gives a static evaluation of a position (i.e. no consideration of the future). Is there anyway to retrieve a time/depth based evaluation as well?

user11245: 
Can anyone supply some code snippets for these instructions? I'm really struggling to find any helpful documentation.

Since you say you need to manipulate chess data structures programmatically, you might find the kind of specific programming guidance you want at the Chess Programming Wiki.
It links to the Universal Chess Interface standard, which Stockfish uses to interface to the chess GUI or other program you're using/writing.

user825: I think you're talking about how to fork a process for the engine and how to use it for the UCI protocol.
What you need to do is:

Fork a new child process for the Stockfish engine
Send and receive UCI commands to/from the engine
Parse the UCI commands yourself

Do you want to study existing source code? Look at:
http://talkchess.com/forum/viewtopic.php?t=57770
Download Chess Game Analyzer, it's a simple Python script for automatic annotation.
When you have the source code, look at the the following:
 p = subprocess.Popen(engineName, stdin=subprocess.PIPE,
                     stdout=subprocess.PIPE,
                     stderr=subprocess.STDOUT)

This line creates a new process for the engine, where engineName is the path of the engine executive.
p.stdin.write("uci\n")

This line sends the uci command to the engine.
for eline in iter(p.stdout.readline, '')

This line parses a UCI response.

user7314: As for the first part, I have been using Perl and the IPC::Open2 package successfully for running Stockfish programmatically. http://perldoc.perl.org/IPC/Open2.html 
As for the UCI way to "get all possible moves", you need to set the "multiPV" parameter to some large value (99?), causing the engine to calculate and report a value for every possible move.
As for making the engine calculate (and report), you use the "go" command.
Try it first interactively from the console to get an idea of what the output looks like, so you can intelligently parse it with your program.

11543: <p>I have Stockfish compiled on my machine. Instead of just running the Stockfish program in the terminal, is it possible to interact with it in a separate program?</p>

<p>For example, some basic things I might want to do:</p>

<ul>
<li>Create a position object from a FEN.    </li>
<li>Get an evaluation from the position object (limiting with depth or time).    </li>
<li>Return an array of positions for all the legal moves from the position.</li>
</ul>

<p>These are just some very basic examples. Can anyone supply some code snippets for these instructions? I'm really struggling to find any helpful documentation.</p>

<p><em>EDIT</em>: It looks like this really has a two part solution. The first is piping the input/output to some external program. The second is understanding the UCI protocol to perform what I want to do. Does anyone know the UCI protocol for getting all of the possible moves/positions from a given position? Also, it looks like the 'eval' command only gives a static evaluation of a position (i.e. no consideration of the future). Is there anyway to retrieve a time/depth based evaluation as well?</p>
 11245: <blockquote>
  <p>Can anyone supply some code snippets for these instructions? I'm really struggling to find any helpful documentation.</p>
</blockquote>

<p>Since you say you need to manipulate chess data structures programmatically, you might find the kind of specific programming guidance you want at the <a href="https://www.chessprogramming.org" rel="nofollow noreferrer"><strong><em>Chess Programming Wiki</em></strong></a>.</p>

<p>It links to the <a href="https://en.wikipedia.org/wiki/Universal_Chess_Interface" rel="nofollow noreferrer"><strong><em>Universal Chess Interface standard</em></strong></a>, which Stockfish uses to interface to the chess GUI or other program you're using/writing.</p>
 825: <p>I think you're talking about how to fork a process for the engine and how to use it for the UCI protocol.</p>

<p>What you need to do is:</p>

<ol>
<li>Fork a new child process for the Stockfish engine</li>
<li>Send and receive UCI commands to/from the engine</li>
<li>Parse the UCI commands yourself</li>
</ol>

<p>Do you want to study existing source code? Look at:</p>

<p><a href="http://talkchess.com/forum/viewtopic.php?t=57770" rel="nofollow">http://talkchess.com/forum/viewtopic.php?t=57770</a></p>

<p>Download <strong>Chess Game Analyzer</strong>, it's a simple Python script for automatic annotation.</p>

<p>When you have the source code, look at the the following:</p>

<pre><code> p = subprocess.Popen(engineName, stdin=subprocess.PIPE,
                     stdout=subprocess.PIPE,
                     stderr=subprocess.STDOUT)
</code></pre>

<p>This line creates a new process for the engine, where <code>engineName</code> is the path of the engine executive.</p>

<pre><code>p.stdin.write("uci\n")
</code></pre>

<p>This line sends the <code>uci</code> command to the engine.</p>

<pre><code>for eline in iter(p.stdout.readline, '')
</code></pre>

<p>This line parses a UCI response.</p>
 7314: <p>As for the first part, I have been using Perl and the IPC::Open2 package successfully for running Stockfish programmatically. <a href="http://perldoc.perl.org/IPC/Open2.html" rel="nofollow">http://perldoc.perl.org/IPC/Open2.html</a> </p>

<p>As for the UCI way to "get all possible moves", you need to set the "multiPV" parameter to some large value (99?), causing the engine to calculate and report a value for every possible move.</p>

<p>As for making the engine calculate (and report), you use the "go" command.</p>

<p>Try it first interactively from the console to get an idea of what the output looks like, so you can intelligently parse it with your program.</p>
