We present a new scheme to extract numerically ``optimal'' interatomic potentials from large amounts of data produced by first-principles calculations. The method is based on fitting the potential to ab initio atomic forces of many atomic configurations, including surfaces, clusters, liquids and crystals at finite temperature. The extensive data set overcomes the difficulties encountered by traditional fitting approaches when using rich and complex analytic forms, allowing to construct potentials with a degree of accuracy comparable to that obtained by ab initio methods. A glue potential for aluminum obtained with this method is presented and discussed.