Start with the easy and cheap things first. Often it's the simple things:
1) Inspect the throttle body bore (and air butterfly blade) for small caked-on fuel deposits. Believe it or not, a little fuel deposits which normally build up in this area (where the butterfly blade seals against the throttole body bore) ...just a little build up can throw off idle. It's a common maintenance item that is often overlooked. They make a throttle body cleaner for that. And get a solvent-safe plastic brush at the parts store (like a slightly larger toothbrush). Never use anything harsh or sharp in there. Allow the solvent to evaporate before you start the vehicle.
2) Inspect your vacuum hoses for cracks or splits. Very likely could be it. If you put a piece of hose on the end of a simple propane torch and wave it around the intake in various areas (not lit of course!), and the engine smooths out then you may have found an intake leak. You can also spray a solvent like the throttle-body cleaner in controlled squirts around the intake to see if the engine smooths out. If not, then you probably don't have a vacuum leak. But if you (or a buddy) has a vacuum gauge, it would be a good idea to hook it up and see what vacuum it's pulling.
3) Check your IAC (Idle Air Control) valve. Carefully remove, clean in the area behind it, let dry, and reinstall. That can cause rough idle. You can use your throttle body cleaner for that job too.
4) Check the PCV valve an all hoses associated with it. I just went through this on a Jeep. Bad idle. Surging. The PCV hose had fallen off ...it was a 2 minute fix! LOL. But also check the pcv valve itself, they can get plugged up and not seal.
5) Temperature sensor. (the one the computer reads off of). These can go bad. When they do, your engine could be warm but the computer 'thinks' it's cold outside, and therefore delivers in incorrect fuel/air mix. The way to check is with a live-read scan tool, or you can simply Ohm out the two pins on the sensor and compare to a ohm chart for your vehicle (google it). But you need to do so cold and warm. They don't always just die, sometimes the sensors 'drift'. If you have a buddy or neighbor with a good scan tool, they can see the temp and compare it to an infra-red temp reading of the engine (plus ambient temp when engine is cold). Autozone and/or OReilly's can read your temps too for free. There's an engine temp and gauge sensor... the engine temp is what your ECU reads to control fuel. Also ...scan for codes too.
6) EGR valve. The valve area gets caked up with carbon and often a good cleaning with a screwdriver resolves the problem. Check the diaphragm that it draws up under vacuum.
7) Any bad coils. You can ohm out ignition coils. Sometimes when they get warm they act 'funny' and can not work well.
8) Just for the heck of it, make sure your battery cables are reasonably clean and your ground is good.
9) Check for any rodent-chewed wires, etc
10) Check fuel pressure. You can borrow a tool from Autozone or OReilly's.
11) O2 Sensor. More than likely it's not the O2, but worth a check if you have a scanner hooked up. It should fluctuate back/fourth.
All the above items are super easy to check (fuel pressure takes a little more). and don't take a lot of time. They can all lead to the problem you're experiencing.